You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I came across few issues with disconnect and reconnect scenarios. I am using C# version of Websocket:
calling websocket.Close() hangs the client when we lose internet connection or when 100% packets drop due to poor connection (this scenario, client is connected to network, there is severe packet loss)
websocket.Close() completes once network connectivity happens. But at that point, there is no reason to disconnect.
I did not check as to when timeout happens after websocket.close() is called and network connectivity never happens. Client hangs for quite a long time on mac.
Note: I have used Network Link Conditioner on Mac to simulate network conditions apart from testing on Windows and Android. Each one of them behaves little differently. This is because OS level network settings.
ClientWebSocket has three methods CloseAsync, CloseOutputAsyncand Abort.
CloseAsync and CloseOutputAsync are for exchanging close frames between Server and Client. This for a more orderly shutdown when client wants to disconnect or server wants to terminate connection.
Abort aborts connection and any pending I/O operations. This is a sync call and returns immediately.
Now coming back to NativeWebSocket, exposes websocket.Close() which calls CloseAsync() on ClientWebSocket. If network is disconnected, there is no point in calling CloseAsync or CloseOutputAsync as they are for terminating connections with acknowledgements. And there is no Abort method exists or a way to access ClientWebSocket as it is private.
For anyone who is curious as to how we detect network disconnects in our client - we use PingPong to send and receive msgs every n seconds/milliseconds. After sending a Ping, we don't receive a Pong within next n milliseconds - it is a disconnect.
I came across few issues with disconnect and reconnect scenarios. I am using C# version of
Websocket
:websocket.Close()
hangs the client when we lose internet connection or when 100% packets drop due to poor connection (this scenario, client is connected to network, there is severe packet loss)websocket.Close()
completes once network connectivity happens. But at that point, there is no reason to disconnect.websocket.close()
is called and network connectivity never happens. Client hangs for quite a long time on mac.Note: I have used Network Link Conditioner on Mac to simulate network conditions apart from testing on Windows and Android. Each one of them behaves little differently. This is because OS level network settings.
ClientWebSocket
has three methodsCloseAsync
,CloseOutputAsync
andAbort
.CloseAsync
andCloseOutputAsync
are for exchanging close frames between Server and Client. This for a more orderly shutdown when client wants to disconnect or server wants to terminate connection.Abort
aborts connection and any pending I/O operations. This is async
call and returns immediately.Now coming back to NativeWebSocket, exposes
websocket.Close()
which callsCloseAsync()
onClientWebSocket
. If network is disconnected, there is no point in callingCloseAsync
orCloseOutputAsync
as they are for terminating connections with acknowledgements. And there is noAbort
method exists or a way to access ClientWebSocket as it is private.For anyone who is curious as to how we detect network disconnects in our client - we use
PingPong
to send and receive msgs every n seconds/milliseconds. After sending a Ping, we don't receive a Pong within next n milliseconds - it is a disconnect.I researched more about
CloseAsync
vsCloseOutputAsync
and came across this article - https://mcguirev10.com/2019/08/17/how-to-close-websocket-correctly.htmlDiscussion points:
Abort
method onWebSocket
in this library ?CloseOutputAsync
be called instead ofCloseAsync
as client is initiating termination of websockets as per this article ?The text was updated successfully, but these errors were encountered: