It appears that when you call Socket.AcceptAsync
with a valid SocketAsyncEventArgs
and have the SocketAsyncEventArgs.Completed
event rigged properly and no connection is accepted for a very long period of time that it just resets the connection. Though, my Socket.ReceiveTimeout
and Socket.SendTimeout
are both zero.
I'm unsure of how to set the timeout for accepting connections and even if it's a good idea at all. Does anyone have a workaround and perhaps some information as to why this is the default behavior?
I filed a bug report on Microsoft Connect to see if they have any reasoning behind why the timeout period is unstable. Sometimes it times out in five minutes and other times more than two hours.
After playing around with this for a bit I have found that a single SYN -> SYN-ACK -> RST sequence will raise the SocketAsyncEventArgs.Completed
event and cause the SocketAsyncEventArgs.SocketError
property to become SocketError.ConnectionReset
. It appears this is expected behavior but it's definitely a gotcha and should be documented better.
Anyone port scanning your server and doing a half-open SYN type scan will generate similar traffic and cause the same problem. To prevent denial of service vulnerabilities in the software, one should be handling this special condition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With