2

I have server client java application running on version SE6. Messaging between server and client is via http protocol. Generally this application was running well but lately I start to see some "connection reset" errors on client side logs. I thought it can be because of keep alive and disabled it but error still there. Here is the client side error log.

java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:208)
    at java.net.SocketInputStream.read(SocketInputStream.java:134)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:247)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:287)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:346)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:717)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:663)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1336)
    at cb.smg.general.utility.ESIHttpCaller.executePost(ESIHttpCaller.java:43)

I know a problem on the server side, if worker thread pool is full socket is closed without and appropriate http code on the server side and client we get java.net.SocketException: Unexpected end of file from server. Bu that should be very rare. My first question can this error(connection reset) be because of some changes outside of application (for instance OS fix.) And secondly what is the best way to handle this exception, currently I just call the below method in finally block.

HttpURLConnection.disconnect()
cacert
  • 2,677
  • 10
  • 33
  • 56
  • possible duplicate of [What's causing my java.net.SocketException: Connection reset?](http://stackoverflow.com/questions/585599/whats-causing-my-java-net-socketexception-connection-reset) – Rudi Kershaw Apr 08 '15 at 09:48
  • I saw that question but since it was with apache http client. I thought may be my problem was related to HTTPUrlconnection. – cacert Apr 08 '15 at 10:11
  • Ah yes, I see that now. Retracted. – Rudi Kershaw Apr 08 '15 at 10:17

1 Answers1

1

if worker thread pool is full socket is closed without and appropriate http code on the server side and client we get java.net.SocketException: Unexpected end of file from server.

Or 'connection reset'. It depends on whether you are reading or writing at that moment.

My first question can this error(connection reset) be because of some changes outside of application (for instance OS fix.)

No.

And secondly what is the best way to handle this exception, currently I just call the below method in finally block.

Good idea.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • thank you for answer. Actually there should be some pool exhausted errors which I dont see in that case. Also I was assuming the error should be "Connection reset by peer" if server closed connection. No ? – cacert Apr 08 '15 at 10:17