doghappy / socket.io-client-csharp

socket.io-client implemention for .NET
MIT License
721 stars 124 forks source link

Socket connect w/ no session ID #280

Open lblast opened 2 years ago

lblast commented 2 years ago

I have experienced problems where the socket connects properly, but there is no session ID. This doesn't happen every time I connect, and typically it happens after the socket has trouble connecting (for example, if WiFi is disabled on the device).

The log when this happens are as follows: SocketIO_OnReconnectError(): Unable to connect to the remote server. SocketIO_OnConnected(): Socket connected, but with no session ID.

I'll note that I'm using v3.0.6 and I experience this on Android devices when I turn the wifi off, wait for socket to try reconnecting, and then turn the wifi back on. On iOS I didn't notice this issue.

doghappy commented 2 years ago

if you switch your network to another, socket.io will be disconnected, and then it will try to reconnect, it will keep trying to reconnect unless the connect successful, you will get a OnReconnectError after each failure.

you mean you can't get session id after to reconnect successful?

could you show me some logs? because I can't repoduce this issue, I haven't Xarmarin enviroment.

https://github.com/doghappy/socket.io-client-csharp/blob/98c2975270c9cadb3bc86f85352a00026efc6209/src/SocketIOClient/Transport/BaseTransport.cs#L157

lblast commented 2 years ago

That is correct, we see the ReconnectError as expected when the wifi is off, and once we turn it back on we will get OnConnected. If I log the session ID in the OnConnected response it is empty, and checking Connected would return "true".

As mentioned, we only noticed this on Android; although the implementation is no different. What additional logs would help you in this case? I will do my best to provide them.

doghappy commented 2 years ago

are you developing on Windows?

Fiddler Classic is a good debug tools for http or websocket, it can record data transferred between client and server, you can choose a session, and then Save it in a ArchiveZip, finally send it to me by email(or upload to here).

if you have any secret in those data, you also can edit ArchiveZip.

if I get an ArchiveZip, I can restore this data in fiddler and then I can analyze the issue.


if you can't use Fiddler, you should clone this repo, add it to your project, then you can record log in here:

https://github.com/doghappy/socket.io-client-csharp/blob/98c2975270c9cadb3bc86f85352a00026efc6209/src/SocketIOClient/Transport/BaseTransport.cs#L157