client `Disconnect ` method blocking issue in 2.6.x
See original GitHub issuehello, I use nuget pkg 2.5.x in a wpf prism project,worked well.
however when I upgarded to 2.6.x to the latest 2.6.x version.the client Disconnect
method seems to blocking main thread.so I wonder if there were some changes in logic in the new version.
2.6 client code via dnspy
public void Disconnect()
{
if (this.IsConnected)
{
Action<string> logger = this.Logger;
if (logger != null)
{
logger(this._header + "disconnecting from " + this.ServerIpPort);
}
this._tokenSource.Cancel();
this._dataReceiver.Wait();
this._client.Close();
this._isConnected = false;
return;
}
Action<string> logger2 = this.Logger;
if (logger2 == null)
{
return;
}
logger2(this._header + "already disconnected");
}
2.5.4 client code via dnspy
public void Disconnect()
{
if (this.IsConnected)
{
Action<string> logger = this.Logger;
if (logger != null)
{
logger(this._Header + "disconnecting from " + this.ServerIpPort);
}
this._TokenSource.Cancel();
this._TokenSource.Token.WaitHandle.WaitOne();
this._Client.Close();
this._IsConnected = false;
return;
}
Action<string> logger2 = this.Logger;
if (logger2 == null)
{
return;
}
logger2(this._Header + "already disconnected");
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to catch a client disconnection when sending a large ...
It removes on finalization (pre 2.6) or on phantom file reference (2.6.x). The easiest way to catch the disconnection is to call Files....
Read more >MQTT disconnects - Tried keepalive but no go. ESP8266 ...
First of all most of the problems with mqtt disconnecting is because bugged esp core. Simply not working good with some wifi chips....
Read more >Karma - Disconnected, because no message in 10000 ms. ...
Try @fluffynuts 's workaround above if you haven't (assuming you ran into the issue after an upgrade to 2.6.X), as it worked for...
Read more >Analyzing Disconnects - Photon Fusion
Client SDKs provide disconnection callbacks and a disconnect cause. Use those to investigate the unexpected disconnects you are having. Here we list the...
Read more >Reading 23: Sockets & Networking
The accept() method is blocking. If no client connection is pending, then accept() waits until a client arrives before returning a Socket object...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, yes, winforms 😃 it gets tricky with winforms. I’m not an expert, but I have experienced interaction with objects blocking the main thread in a forms app. Probably best to have it in a background task.
thanks for your reply!