AndroidAsync icon indicating copy to clipboard operation
AndroidAsync copied to clipboard

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

Open ManuKow opened this issue 3 years ago • 1 comments

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) { } });

ManuKow avatar Apr 25 '22 07:04 ManuKow

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.

Zhoros avatar Oct 17 '22 09:10 Zhoros