AcceptTcpClientAsync can also throw SocketException #130
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It seems the call to
AcceptTcpClientAsync
insmtpserver/Rnwood.SmtpServer/SmtpServer.cs
Line 254 in 56702c5
SocketException
, as documented in https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.tcplistener.accepttcpclientasync?view=net-5.0#exceptionsInteresting enough I am getting the following stacktrace on disposing of
SmtpServer
instances randomly!Hence the reason for this PR.
I tried to reproduce this exception in your tests but was unable, I am using net5 on my solution, so not sure if it has something to do with it or not.
The good news is that once I applied this patch locally I can no longer reproduce this exception.
Can you please consider this PR as an extra improvement to this awesome lib?