D
D
Dimash Kenzhegaliev2021-04-08 23:41:04
JavaScript
Dimash Kenzhegaliev, 2021-04-08 23:41:04

Will ws disconnect from the server if the mobile application is closed?

i create a ws client/server connection when the mobile application is launched, the question is when will this connection break? send notification to user ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DromHour, 2021-04-09
@Giranda22-Git

The socket must not be disconnected while the application is active. If it is put to sleep by the system, then it will need to reconnect:

ws.onclose = function(e) {
    console.log('Socket is closed. Reconnect will be attempted in 1 second.', e.reason);
    setTimeout(function() {
      connect();
    }, 1000);
  };

The best option to keep the app always open is to keep a persistent push notification

V
Vladislav Argun, 2021-04-09
@Vladislav_Argun

If your application is not running in the background, then yes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question