Websocket connnection lost in app background

Hey, we are using React-Native-SDK in our app. While the app goes to the background we got the below error and real-time stopped working but specifically in Android.

[FROM SERVER] - [event: error] - arguments: {“type”:“TransportError”,“description”:{“isTrusted”:false,“message”:“Code 1005 is reserved and may not be used.”}}

Any idea about the error please and If the web socket is not stable then how can we fix the issue?

Hello @Baljeet_Singh,

I’ve created an internal ticket BKNDLSS-25552 to investigate this issue.
Maybe this topic could be useful?

Regards,
Olha

@olhadanylova But how it will work with react native, do I need to install the socket.io-client to check the status of the connection ?

Hello @Neeraj_Kumar,

Socket-IO is already integrated the RN library. You can check the connectivity using these listeners.

Regards,
Olha

@olhadanylova But this transport error is not calling any of the defined listeners, that is the major concern here

Following I have observed till now

Connect event - Calling the connect listener
Disconnect event - Calling the disconnect listener

@olhadanylova is there any way we can get this error in the listeners events ?

Hello @Neeraj_Kumar,

we need more time to investigate the issue, I will increase priority for BKNDLSS-25552 ticket

Looking forward to the solution @sergey.kuk

@sergey.kuk any update on this ?

@olhadanylova Can we make a connection to socket explicitly ?

You can see how it is done in our sdk which is open source. If you try connecting directly, we would not be able to provide support and answer questions about that integration

@mark-piller I have been waiting for the fix where as soon as the application comes to background, I got the above reported transport error, If possible can you let me know how I can bypass this error so that listeners should work fine

I was answering to the immediate question you posted (connecting directly)

@mark-piller I am trying to find a workaround because our real time update stopped working as soon as application goes to background. Is there any way I can change the transport to WEBSOCKET, I have seen on many places, we will get the transport error only when the transport is set to POLLING.

Hello @Neeraj_Kumar

Are you sure that WEBSOCKET should work when app goes to background, as far as I know some OS blocks any API when an app is not active?

Could you please add listeners for the following events:

Backendless.RT.addConnectEventListener(callback: () => void): void;
Backendless.RT.addConnectErrorEventListener(callback: (error: string) => void): void;
Backendless.RT.addDisconnectEventListener(callback: () => void): void;
Backendless.RT.addReconnectAttemptEventListener(callback: (attempt: number, timeout: number) => void): void;

Yeah I have added those listeners, but that transport error is not getting logged in any of that event.
Let’s assume, websocket does not work in the background, how we can perform the updates in the background If something has been updated, any thoughts on this ?

If the user cannot see the interface, what is the point of updating something?

@mark-piller Imagine, there are 100 things in an app, and whenever user will open the app which was in background, is it okay to fetch the data for those 100 things or, we should update the app when the app is in the background ?