Dear Jose, > 2012/5/22 Kees Jan Koster <kjkos...@gmail.com>: >> Dear Tomcat community, >> >> I am trying to resolve the problem where some client code in Java frequently >> gets the following error in the logs: >> >> java.net.SocketException: Connection reset >> at java.net.SocketInputStream.read(SocketInputStream.java:168) >> at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) >> at java.io.BufferedInputStream.read1(BufferedInputStream.java:258) >> at java.io.BufferedInputStream.read(BufferedInputStream.java:317) >> at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687) >> at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632) >> at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:652) >> at >> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1000) >> ... >> > > Are you calling to disconnect() method ?
Yes I am. In finally{} block. Here is the client code: private Properties push(final Properties request) throws IOException { HttpURLConnection connection = null; PrintStream out = null; InputStream in = null; try { connection = (HttpURLConnection) pushUrl.openConnection(proxy); connection.setRequestMethod("POST"); connection.setDoOutput(true); connection.setConnectTimeout(TWO_MINUTES); connection.setReadTimeout(TWO_MINUTES); connection.setRequestProperty("Connection", "close"); out = new PrintStream(connection.getOutputStream()); request.storeToXML(out, null); out.flush(); in = connection.getInputStream(); final Properties response = new Properties(); response.loadFromXML(in); return response; } finally { if (in != null) { try { in.close(); } catch (Exception e) { // ignore... } } if (out != null) { try { out.close(); } catch (Exception e) { // ignore... } } if (connection != null) { try { connection.disconnect(); } catch (Exception e) { // ignore... } } } } } -- Kees Jan http://java-monitor.com/ kjkos...@kjkoster.org +31651838192 Human beings make life so interesting. Do you know that in a universe so full of wonders, they have managed to invent boredom. Quite astonishing... -- Terry Pratchett --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org