Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7658711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:14:14+00:00 2026-05-31T13:14:14+00:00

I have two Tomcat servers that need to maintain a persistent connection to cut

  • 0

I have two Tomcat servers that need to maintain a persistent connection to cut down on SSL handshaking. One server (the proxy) sits in a DMZ while the other one is safely behind another firewall. The proxy basically just runs a simple servlet that does some sanity checking before forwarding requests over to the secure machine. On an intial request the machines exchange certificates before performing the real work. Therefore I’d like to maintain a persistent connection with a timeout of a few minutes.

To talk to the secure server, the servlet on the proxy uses HttpsUrlConnection. I’ve set up WireShark and I’ve noticed that no matter what keepAliveTimeout value I set for connector on the secure machine, the TCP connection gets closed after about 5 or 10 seconds. This number seems to match up with what I’ve read is the default timeout and how Java handles HTTP Keep-Alive. This link explains that Java honors the Keep-Alive timeout if it is sent by the server, otherwise it uses 5 seconds (direct connections) or 10 seconds (proxy connections) before it closes the connection.

What I’m trying to figure out is how can I force Tomcat to send the Keep-Alive header. Not, Connection: Keep-Alive, but Keep-Alive: timeout=x.

I’ve experimented with Apache HTTP server and modifying the keepAliveTimeout in httpd.conf does cause the Keep-Alive header to change its timeout value. Furthermore Java does honor this timeout.

UPDATE (12/23/11): After running a few more experiments I tried whipping up some quick and dirty code using Apache’s HttpClient (3.1) rather than HttpsUrlConnection. It appears that HttpClient, when set to use Keep-Alive, simply waits for the server to close the connection. I don’t know how long it will wait though. I’m shooting to keep the HTTP connection alive for 3 to 5 minutes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:14:15+00:00Added an answer on May 31, 2026 at 1:14 pm

    I was able to use HttpClient 3.1 to hold the HTTP connection open for 5 minutes by setting the keepAliveTimeout in the Tomcat connector to 300000. I verified it using WireShark that the server will terminate the connection while HttpClient will simply wait. Subsequent requests through HttpClient reuses the existing TCP connection (avoiding any further SSL handshaking). The key there though is to have a single HttpClient instance (i.e. not creating one each time). This might be obvious to most but I wasn’t sure what the API mechanics for HTTPClient would be. In short, create one HttpClient instance and for each request (POST, GET, etc.) create a new PostMethod, GetMethod, etc. This will cause the TCP connection to be reused.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two web applications that are running on a single Tomcat server and
I have two servers with Apache Tomcat that once in a while, connect to
I have a tomcat server with two webapps (foo and bar) that have an
I have two tomcat web applications that need to share information using a singleton.
I have Tomcat 6.0.24 64 bit installed on two Windows Server 2008 boxes as
I have two requests in tomcat. One HTTP request will create a thread. Client
I have two application that need to talk to each other. App1 needs to
I have two tomcat servers running at the same time. I have reports which
I have two Virtual machines on an external server. VM1 is the Tomcat server
I have the following arrangement : Tomcat --EJB-invokation--> JBoss (6.0.14) (5.1.0) The two servers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.