I have java http client which sends periodically (every 30 sec; this code is run by heartbeat thread in the cycle) heartbeats
private PostResponse post(String jSessionCookie, final String action, final String data, final int postTimeoutMs) throws IOException, SSYSException { final HttpURLConnection httpConn = openHttpUrlConnection(true, postTimeoutMs, jSessionCookie); final OutputStream os = httpConn.getOutputStream(); try (final PrintWriter wr = new PrintWriter( DefaultProperty.isEnableSocketTraceGW ? new TracerOutputStream(os) : os )) { final String text = "action=" + action + "&data=" + URLEncoder.encode(data, DefaultProperty.httpEncoding); wr.write(text); wr.flush(); final int respCode = httpConn.getResponseCode(); if (respCode != HttpURLConnection.HTTP_OK) { String info = "Incorrect response from server, responseCode:" + respCode + ", message:" + httpConn.getResponseMessage(); log.error(info); throw new SSYSException(SSYSCoreEx.ERR_UNKNOWN_ERROR, info); } } if (jSessionCookie == null) { jSessionCookie = getJSessionCookie(httpConn); } final InputStream inputStream = httpConn.getInputStream(); try (final BufferedReader reader = new BufferedReader(new InputStreamReader( (DefaultProperty.isEnableSocketTraceGW ? new TracerInputStream(inputStream) : inputStream ) , DefaultProperty.httpEncoding))) { log.trace("before readline(post)"); String replyText = reader.readLine(); log.trace("after readline(post): [" + replyText + "]"); NReply nReply = PoolGson.fromJson(replyText, NReply.class); if (nReply == null) { final String msg = "corrupted reply, action:" + action; log.debug(msg); throw new IOException(msg); } return new PostResponse(replyText, nReply, jSessionCookie, nReply.id); } } On the server side there is Tomcat 8.0.21 + APR connector. Every time this heartbeat is sent I see in the Wireshark and EtherDetect that new TCP connection is opened (SYN-SYNACK packets) and after getting response from Tomcat connection is closed (FIN – FINACK packets). I was expecting that TCP connections will be reused but not closed. Is it problem in my client or it can be solved by Java and/or Tocmat configuration?
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org