Closed raufismayilov closed 5 months ago
Thank you Rauf for working on this issue. It was also reported in #246 but you've provided more technical information that better explained this issue and a possible solution which is always helpful.
This is most likely caused by the fact that when the socket is closed Socket.EndReceive is not called in OnClientSockerReceived. The same applies to Smb1Client as well
Can this be because Socket.Close is not called in OnClientSockerReceived? I appreciate this theory, but a more concrete analysis will be much more helpful.
You can ensure that Socket.EndReceive is always called and you will see that Unobserved exceptions are gone. This is your current check that prevents from this to happen:
if (!clientSocket.Connected)
{
state.ReceiveBuffer.Dispose();
return;
}
Thanks again Rauf, I have removed that piece of code and ran several tests - but I did not suffer from the issue to begin with - so I'm not sure that I can declare that the fix is verified. Can please you run it as well verify that this specific issue is solved in the latest master?
Hello TelAloni, I will do the test and let you know, in the meantime, if you want I can set up a call and demo the issue.
Thanks, I'm waiting to hear if there is an issue following the latest change. if there is no issue anymore - no need to demo it.
Hello TalAloni, We have tested and can confirm that your changes fixed UnobservedTaskException's. Just in case, NullReferenceException's have also gone and don't cause application crashes anymore.
Thank you Rauf for the testing and assistance!
This issue has been solved in v1.5.2
Calling Smb2Client.Disconnect causes UnobservedTaskExceptions. This happens even if just Smb2Client.Connect and then Smb2Client.Disconnect is called. On Linux the error is as follows:
On Windows the error is
System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request.
This is most likely caused by the fact that when the socket is closed Socket.EndReceive is not called in OnClientSockerReceived. The same applies to Smb1Client as well