Java.Net.Socketexception: Connection Reset

What's causing my java.net.SocketException: Connection reset?

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.

Getting java.net.SocketException Connection reset error in socket communication with threads

java.net.SocketException: Connection reset

This means the OS has reseted the connection because the process on the other end is no longer running. It looks like your client crashes after processing first reply from the server.

Scanner scanner = new Scanner(System.in);
scanner.close();

Do not close Scanners operating on System.in. This will close System.in and you will not be able to read anything anymore from there.



Related Topics



Leave a reply



Submit