koush / AndroidAsync

Asynchronous socket, http(s) (client+server) and websocket library for android. Based on nio, not threads.
Other
7.51k stars 1.56k forks source link

Callback is not received when network is poor and connection is terminated from other End #709

Open ManuKow opened 2 years ago

ManuKow commented 2 years ago

When we have used the library to connect to an backend and the signal strength is very poor and the backend has terminated the connection, we do not get call back this.socket.setClosedCallback(new CompletedCallback() { public void onCompleted(Exception var1) { } });

NRicode commented 1 year ago

https://github.com/websockets/ws#how-to-detect-and-close-broken-connections you need to detect it by yourself, this is called ping pong / heartbeat method, where you send frequent packet e.g every 10 second and if the client does not reply in e.g 5 second you terminate the connection. I hope this help other ppl aswell.