socket.io-client-dart
socket.io-client-dart copied to clipboard
Android: Makes multiple calls for connection
I'm using this with Socketio on the node server. For the first time when the app launches, only 1 call is made to establish a connection which is expected. But if you minimize the app and lock your phone (I was testing it on the emulator), after the socket disconnects, reopen the application and let it auto connect. Now here it makes multiple calls for connection. If the above steps make say 2 connection requests, then at the time of disconnect the server shows the reason of disconnect as transport close and ping timeout for these connection requests. I have even seen 10-12 connection requests by minimizing and reopening several times followed by the above-mentioned steps. I didn't test it on iOS or the web.
I also i am facing same issue i solve by adding enableForceNewConnection()
socket = io(
'your socket url,
OptionBuilder()
.setTransports(['websocket'])
//add this line
.enableForceNewConnection() // necessary because otherwise it would reuse old connection
.disableAutoConnect()
.build());
maybe a little stupid, socket_io_client caches and reuses socket objects by default, Closing the socket also does not delete the cache, So the listeners set every time you connect will be added to the same socket object, resulting in duplicate callbacks,
Also I suspect this will cause a memory leak,
Same issues here in version 2.0.0
Same issue here. When I disconnect and connect again it fires multiple disconnect & connect events. Version: 2.0.3+1