I am currently trialing Stream Chat at work and have a working implementation using the stream-chat-js
directly within our React Native project. I have a query surrounding when/how the SDK decides to perform the _reconnect
action. Understanding this will help us avoid "dropping" messages when a user backgrounds the mobile app (i.e. the user can't see the app) but the backing web-socket connection is still available.
>> Start
>> User 1 is viewing their inbox of messages here:
08-14 17:59:00.533 6564 6851 I ReactNativeJS: 'info', 'client: post - Request - https://chat-us-east-1.stream-io-api.com/channels/messaging/classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351/query'
08-14 17:59:00.681 6564 6851 I ReactNativeJS: 'info', 'client:post - Response - url: https://chat-us-east-1.stream-io-api.com/channels/messaging/classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351/query > status 201'
>> User 1 and User 2 start chatting here:
08-14 17:59:00.748 6564 6851 I ReactNativeJS: 'info', 'channel:watch() - started watching channel messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:00.750 6564 6851 I ReactNativeJS: 'info', 'client: post - Request - https://chat-us-east-1.stream-io-api.com/channels/messaging/classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351/message'
08-14 17:59:00.836 6564 6851 I ReactNativeJS: 'info', 'client: post - Request - https://chat-us-east-1.stream-io-api.com/channels/messaging/classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351/event'
08-14 17:59:00.869 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.new }'
08-14 17:59:00.869 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.new } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:01.286 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.new }'
08-14 17:59:01.286 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.new } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:01.290 6564 6851 I ReactNativeJS: 'info', 'client:post - Response - url: https://chat-us-east-1.stream-io-api.com/channels/messaging/classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351/message > status 201'
08-14 17:59:01.293 6564 6851 I ReactNativeJS: 'info', 'client: get - Request - https://chat-us-east-1.stream-io-api.com/channels'
08-14 17:59:01.297 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.new }'
08-14 17:59:01.297 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.new } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:01.659 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.new }'
08-14 17:59:01.659 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.new } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:01.826 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { typing.stop }'
08-14 17:59:01.827 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { typing.stop } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:01.829 6564 6851 I ReactNativeJS: 'info', 'client:post - Response - url: https://chat-us-east-1.stream-io-api.com/channels/messaging/classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351/event > status 201'
08-14 17:59:01.831 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { typing.stop }'
08-14 17:59:01.831 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { typing.stop } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:01.831 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { typing.stop }'
08-14 17:59:01.831 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { typing.stop } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:01.832 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { typing.stop }'
08-14 17:59:01.832 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { typing.stop } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:01.843 6564 6851 I ReactNativeJS: 'info', 'client:get - Response - url: https://chat-us-east-1.stream-io-api.com/channels > status 200'
08-14 17:59:03.637 6564 6851 I ReactNativeJS: 'info', 'client: post - Request - https://chat-us-east-1.stream-io-api.com/channels/messaging/classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351/stop-watching'
08-14 17:59:03.781 6564 6851 I ReactNativeJS: 'info', 'client:post - Response - url: https://chat-us-east-1.stream-io-api.com/channels/messaging/classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351/stop-watching > status 201'
>> User 1 backgrounds their app here:
08-14 17:59:03.782 6564 6851 I ReactNativeJS: 'info', 'channel:watch() - stopped watching channel messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
>> User 2 starts their response to User 1 here:
08-14 17:59:08.955 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { typing.start }'
08-14 17:59:08.956 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { typing.start } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:08.988 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { typing.start }'
08-14 17:59:08.988 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { typing.start } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:09.109 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { typing.start }'
08-14 17:59:09.110 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { typing.start } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:09.772 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.read }'
08-14 17:59:09.773 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.read } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:09.807 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.read }'
08-14 17:59:09.807 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.read } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:09.811 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.read }'
08-14 17:59:09.811 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.read } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:12.028 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { typing.stop }'
08-14 17:59:12.028 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { typing.stop } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:12.134 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { user.watching.start }'
08-14 17:59:12.134 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { user.watching.start } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:12.135 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { typing.stop }'
08-14 17:59:12.135 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { typing.stop } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:12.136 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { user.watching.start }'
08-14 17:59:12.136 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { user.watching.start } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:12.136 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { typing.stop }'
08-14 17:59:12.137 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { typing.stop } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:12.184 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { user.watching.start }'
08-14 17:59:12.184 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { user.watching.start } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
>> User 1 gets a notification.message_new event here but the app is backgrounded so our app process does not respond:
08-14 17:59:12.186 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { notification.message_new }'
08-14 17:59:12.243 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { notification.message_new } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:12.244 6564 6851 I ReactNativeJS: 'info', 'client: get - Request - https://chat-us-east-1.stream-io-api.com/channels'
08-14 17:59:12.251 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { notification.message_new }'
08-14 17:59:12.252 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.new }'
08-14 17:59:12.252 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.new } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:12.256 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.new }'
08-14 17:59:12.256 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.new } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:12.562 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.new }'
08-14 17:59:12.562 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.new } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:12.733 6564 6851 I ReactNativeJS: 'info', 'client:get - Response - url: https://chat-us-east-1.stream-io-api.com/channels > status 200'
08-14 17:59:19.704 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.read }'
08-14 17:59:19.704 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.read } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:19.707 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.read }'
08-14 17:59:19.708 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.read } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:19.710 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.read }'
08-14 17:59:19.710 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.read } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:26.055 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.read }'
08-14 17:59:26.056 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.read } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:26.059 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.read }'
08-14 17:59:26.059 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.read } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:26.063 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.read }'
08-14 17:59:26.063 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.read } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:32.301 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.read }'
08-14 17:59:32.301 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.read } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:32.304 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.read }'
08-14 17:59:32.305 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.read } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
08-14 17:59:32.307 6564 6851 I ReactNativeJS: 'info', 'client:_handleClientEvent - Received event of type { message.read }'
08-14 17:59:32.308 6564 6851 I ReactNativeJS: 'info', 'channel:_handleChannelEvent - Received event of type { message.read } on messaging:classifieds__41909b8e_805d_4920_bb4d_0b57ef70f2ce__4063__5351'
>> User 1's client issues a "reconnect" command here meaning that subsequent messages from User 2 will be delivered via Push:
08-14 17:59:34.567 6564 6851 I ReactNativeJS: 'info', 'connection:_reconnect() - Initiating the reconnect'
08-14 17:59:34.602 6564 6851 I ReactNativeJS: 'info', 'connection:_reconnect() - Initiating the reconnect'