doghappy / socket.io-client-csharp

socket.io-client implemention for .NET
MIT License
729 stars 125 forks source link

Invalid state. #249

Closed adeelarshad83 closed 2 years ago

adeelarshad83 commented 2 years ago

I am using version 3.0.4 and facing this issue at sometime of the day but not consistent.

Error: System.Net.WebSockets.WebSocketException (0x80004005): The WebSocket is in an invalid state ('Aborted') for this operation. Valid states are: 'Open, CloseReceived'

How can I check state before sending data

doghappy commented 2 years ago
            if (socket.Connected)
            {
                try
                {
                    await socket.EmitAsync("hi", "test");
                }
                catch (Exception)
                {
                    // retry or other ...
                }
            }
adeelarshad83 commented 2 years ago

Thank you so much