socket.io-client-dart icon indicating copy to clipboard operation
socket.io-client-dart copied to clipboard

disconnects after 2 hours.

Open softmarshmallow opened this issue 5 years ago • 9 comments

is there any possibility of this library is miss configured and disconnects connection after 2 hours? I'm sorry i do not have any logs or debug information, but client keeps saying that the connection gets lost every 2 hours (approx)

i my self tested, the connection lasts for 10 hours, sometimes shorter. the server works fine, guess something magic is happening on serverside, which closes the connection automatically after long time..

softmarshmallow avatar Apr 26 '20 09:04 softmarshmallow

@softmarshmallow In my case Connection lost and connect again after every 10 seconds Can u please let me know did u implement Ping/Pong on server side. Its very helpful for me Thanks

vikas-shrma avatar Apr 26 '20 11:04 vikas-shrma

feel free to take a look

https://github.com/softmarshmallow/inked-flutter https://github.com/softmarshmallow/inked-server

softmarshmallow avatar Apr 27 '20 01:04 softmarshmallow

Were you able to solve the issue @softmarshmallow or @jumperchen ?

Because when my app is in background, the socket is getting disconnected from the server, and then automatically connects to it. It stays 13s connected, then it disconnects and stays disconnected for 10~ seconds.

But that does not happen when my app is in foreground.

I need to get notifications from the socket server, but when it always gets disconnected when phone is locked or app is in background, I am missing the "notifications" aka socket emits statements from the server are not coming, because like 50% of the time its disconnected.

Norair1997 avatar Dec 03 '20 20:12 Norair1997

Nope, did not solve it.

softmarshmallow avatar Dec 04 '20 01:12 softmarshmallow

@Norair1997 I'm not an expert for Flutter dev. But it seems to happen on how to run websocket in background service for android and ios. Here is the one who asked on stackoverflow for flutter - https://stackoverflow.com/questions/50538962/flutter-run-websocket-on-background

jumperchen avatar Dec 04 '20 02:12 jumperchen

@Norair1997 I'm not an expert for Flutter dev. But it seems to happen on how to run websocket in background service for android and ios. Here is the one who asked on stackoverflow for flutter - https://stackoverflow.com/questions/50538962/flutter-run-websocket-on-background

NOT FIX THIS!

loidoan avatar May 22 '21 04:05 loidoan

Do you guys have any solutions?

loidoan avatar Dec 28 '21 12:12 loidoan

I think you guys should try Firebase Cloud Messaging for all server to client messages. There are two approaches to this:

  1. Firebase + socket.io : This is a bit complicated and requires server side logic to route messages through socket.io when the client is connected or route it through Firebase when the client is disconnected.

  2. Firebase only: Notifications can directly be sent through firebase. Or you can use the data message packet to trigger functions that generate the notification on your client device.

I haven't tested socket.io in background, but I have tested Firebase data messages and they deliver almost 100% of the time. I would not depend on the app to keep an active socket.io connection in the background.

Advait1306 avatar Jan 24 '22 05:01 Advait1306

Do you guys have any solutions without using firebase?

michaelnabil230 avatar Sep 12 '23 21:09 michaelnabil230