socket.io-client-csharp
socket.io-client-csharp copied to clipboard
OnDisconnected issue on Raspberry Pi/NET 6
Hi,
on Raspberry Pi 4 , Arch64, Linux Debian 11, .NET 6, we have a problem with getting rise OnDisconnected event. Steps to reproduce
- start application with disconnected network cable
- plug in network cable -> OnConnected event rise on about 3sec, that is OK
- unplug network cable -> OnDisconnected event rise after about 18 minutes, that is NOK
On Windows 10 and Windows WSL (Debian) it seems to works fine. Did you meet such a problem? Do you have any suggestions what is wrong with it?
Thanks for any help.
The issue can be reproduced.
- create an ARMx64 VM on Azure.
- drop a ip rule from iptables
logs:
04/18/2024 14:27:02 OnPong: 00:00:00.0000438
04/18/2024 14:27:07 Ping
04/18/2024 14:27:07 OnPong: 00:00:00.0000423
04/18/2024 14:27:12 Ping
04/18/2024 14:27:12 OnPong: 00:00:00.0000620
04/18/2024 14:27:18 Ping
04/18/2024 14:27:18 OnPong: 00:00:00.0000721
04/18/2024 14:44:48 Disconnected
04/18/2024 14:45:09 OnReconnectAttempt: 1
04/18/2024 14:45:30 OnReconnectAttempt: 2
04/18/2024 14:45:51 OnReconnectAttempt: 3
04/18/2024 14:46:12 OnReconnectAttempt: 4
04/18/2024 14:46:33 OnReconnectAttempt: 5
04/18/2024 14:46:54 OnReconnectAttempt: 6
04/18/2024 14:47:15 OnReconnectAttempt: 7
04/18/2024 14:47:36 OnReconnectAttempt: 8
it takes 17 mins to get Disconnected event.
The issue is not limited to ARM devices; it also occurs on Ubuntu x64. Because the TCP connection is not properly closed, different operating systems have different implementations, resulting in different TCP configurations.
I attempted to reproduce the issue by using the ClientWebSocket
class in C# to directly connect to a WebSocket server and then dropping the connection from iptables.
Even after switching to Node.js, the disconnection may not be 'immediately' detected.
Interestingly, when I allowed access to the WebSocket server in iptables, the connection immediately resumed as if the network had not been disconnected.
"I encountered the same issue. I directly unplugged the server's network cable, and when the client did not receive a heartbeat from the server for 90 seconds, it would actively call await _socket.DisconnectAsync(); //
However, this call takes 14 minutes to complete according to tests. Is there a way to resolve this?"