Not able to recieve data on manual disconnection and Connecting.
Am currently using socket_io_client: 0.9.12, sice I hav not migrated to flutter 2.x, So when am connecting to the socket on the app Cold start, the socket works fine, am able to observe my custom event. So upon manual disconnection and reinitialization to connect, am not able to receive any data in my custom socket event, and am able to observe connected ping & pong events. this even occurs after the socket's dispose and disconnect is called. even on assigning null to the socket instance and reinitialization.
to resolve this after skimming through the code, within the lib\socket_io_client.dart file, It seems there is an instance maintained, so on reconnection, if the URL domain is the same, it uses multiplexing, But ideally, it should work on connecting to the same URL. but didn't,
So I am passing
['forceNew'] = true or
opts['force new connection'] = true
while initializing the socket, which simply forces a new connection. and it is working for the above-said scenario I would like to know if this is the right way, If so I can make a pull request and make the necessary changes.
I'm using socket_io_client: 2.0.0-beta.4-nullsafety.0
And I can confirm the scenario. It happens for me as well.
while initializing the socket, which simply forces a new connection. and it is working for the above-said scenario I would like to know if this is the right way, If so I can make a pull request and make the necessary changes.
You mean something like this?
final options = IO.OptionBuilder()
.setTransports(['websocket']).setAuth({"token": token.token}).build();
options['force new connection'] = true;
options['forceNew'] = true;
IO.Socket socket = IO.io(u, options);
And you attach your listeners on reconnect?
Yes , Listeners can be either maintained or listeners can reattched. But ideally the reason I opened this issue is , it doesn't actually need to happen his way.