Have you ever gotten this error?
System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine.
I have recently encountered this error when calling Net.HttpWebRequest.GetRequestStream as part of an asynchronous request to an Apache server. After some hunting, I found the solution inside of this Microsoft Forum: set the KeepAlive property of the request to “false”. That’s it. I just want to thank Microsoft for helping me keep my skill of bizarre workarounds alive.
Here’s the full stack trace, for search engines.
System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
— End of inner exception stack trace —
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.InternalWrite(Boolean async, Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
at System.Net.ConnectStream.Write(Byte[] buffer, Int32 offset, Int32 size)
For the record, this is while doing a POST, and I’m also setting the Expect-100 header to false as well, as described here.




Comments are closed.