Official reasons for "Software caused connection abort: socket write error"

Eran Medan picture Eran Medan · Jan 24, 2010 · Viewed 329.3k times · Source

Given this stack trace snippet

Caused by: java.net.SocketException: Software caused connection abort: socket write error
 at java.net.SocketOutputStream.socketWrite0(Native Method)

I tried to answer the following questions:

  1. What code is throwing this exception? (JVM?/Tomcat?/My code?)
  2. What causes this exception to be thrown?

Regarding #1:

Sun's JVM source doesn't contain this exact message, but I think the text Software caused connection abort: socket write error is from the native implementation of SocketOutputStream:

private native void socketWrite0(FileDescriptor fd, byte[] b, int off,
                 int len) throws IOException;

Regarding #2

My guess is that it is caused when the client has terminated the connection, before getting the full response (e.g. sent a request, but before getting the full response, it got closed / terminated / offline)

Questions:

  1. Are the above assumptions correct (#1 and #2)?
  2. Can this be diffrentiated from the situation: "could not write to the client, due to a network error on the server side"? or would that render the same error message?
  3. And most important: Is there an official document (e.g from Sun) stating the above?

I need to have a proof that this stack trace is the socket client's "fault", and there is nothing that the server could have done to avoid it. (except catching the exception, or using a non Sun JVM SocketOutputStream, though both don't really avoid the fact the client has terminated)

Answer

Marquis of Lorne picture Marquis of Lorne · Oct 13, 2011

This error can occur when the local network system aborts a connection, such as when WinSock closes an established connection after data retransmission fails (receiver never acknowledges data sent on a datastream socket).

See this MSDN article. See also Some information about 'Software caused connection abort'.