tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jose María Zaragoza <demablo...@gmail.com>
Subject Re: connection reset errors
Date Tue, 22 May 2012 09:59:02 GMT
> Yes I am. In finally{} block. Here is the client code:

Calling the disconnect() method of HttpURLConnection may close the
underlying socket
if a persistent connection is otherwise idle at that time
Try don't call it,  test it and tell us :-)

http://docs.oracle.com/javase/1.5.0/docs/guide/net/http-keepalive.html


>
>    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/
> kjkoster@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-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message