What's causing my java.net.SocketException: Connection reset? [duplicate]
Solution 1:
The javadoc for SocketException states that it is
Thrown to indicate that there is an error in the underlying protocol such as a TCP error
In your case it seems that the connection has been closed by the server end of the connection. This could be an issue with the request you are sending or an issue at their end.
To aid debugging you could look at using a tool such as Wireshark to view the actual network packets. Also, is there an alternative client to your Java code that you could use to test the web service? If this was successful it could indicate a bug in the Java code.
As you are using Commons HTTP Client have a look at the Common HTTP Client Logging Guide. This will tell you how to log the request at the HTTP level.
Solution 2:
This error happens on your side and NOT the other side. If the other side reset the connection, then the exception message should say:
java.net.SocketException reset by peer
The cause is the connection inside HttpClient
is stale. Check stale connection for SSL does not fix this error. Solution: dump your client and recreate.
Solution 3:
If you experience this trying to access Web services deployed on a Glassfish3 server, you might want to tune your http-thread-pool settings. That fixed SocketExceptions we had when many concurrent threads was calling the web service.
- Go to admin console
- Navigate to "Configurations"->"Server config"->"Thread pools"->"http-thread-pool".
- Change setting "Max Thread Pool Size" from 5 to 32
- Change setting "Min Thread Pool Size" from 2 to 16
- Restart Glassfish.
Solution 4:
I did also stumble upon this error. In my case the problem was I was using JRE6, with support for TLS1.0. The server only supported TLS1.2, so this error was thrown.
Solution 5:
In my case, this was because my Tomcat was set with an insufficient maxHttpHeaderSize
for a particularly complicated SOLR query.
Hope this helps someone out there!