13

I'm using Tomcat 6.0.24 on Ubuntu (JDK 1.6) with an app that does Comet-style requests on an HTTPS connector (directly against Tomcat, not using APR).

I'd like to set the keep-alive to 5 minutes so I don't have to refresh my long-polling connections. Here is my config:

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
           maxThreads="1000"  keepAliveTimeout="330000"
        scheme="https" secure="true"
           clientAuth="false" sslProtocol="TLS" />

Unfortunately it seems that the server closes the connection after 65 seconds. The pcap from a sample session goes something like this:

T=0   Client sends SYN to server, handshake etc.
T=65  Server sends FIN to client
T=307 Client sends FIN to server

(I'm guessing the 5 minute timeout on the client is due to the HTTP lib not detecting the socket close on the server end, but in any case -- the server shouldn't be closing the connection that early)

(edit: this works as expected when using the standard HTTP connector)

5 Answers 5

14

Amazon's ELB (Elastic Load Balancer) has an undocumented (except on forums) 60-second timeout which will tear down the connection if no data was sent. Hacking around by sending whitespace every 55 seconds seems like it'll work until they make this configurable.

3
11

The load balancer timeout, which closes the connection, is now documented:

To configure the idle timeout setting for your load balancer

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
  2. In the navigation pane, under LOAD BALANCING, click Load Balancers.
  3. Select your load balancer.
  4. In the bottom pane, select the Description tab.
  5. Find Connection Settings, and then click (Edit).
  6. In the Configure Connection Settings dialog box, enter a value for Idle Timeout. The range for the idle timeout is 1 to 3,600 seconds.
  7. Click Save.
1
  • 1
    This should now be the accepted answer.
    – jonatan
    Sep 23, 2016 at 15:56
2

The timeout for inactive connections is mentioned in the health check troubleshooting section: http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/DeveloperGuide/ts-elb-healthcheck.html

0

The ELB Idle Timeout range is updated and it can be from 1 second (minimum) upto 4000 seconds (maximum), and the default value for idle timeout is 60 seconds.

https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/config-idle-timeout.html

0

From AWS documentation can one please clarify this statement. https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/config-idle-timeout.html

You can enable keep-alive in the web server settings for your instances. Keep-alive, when enabled, enables the load balancer to reuse back-end connections until thekeep-alive timeoutexpires. To ensure that the load balancer is responsible for closing the connections to your instance, make sure that the value you set for the HTTPkeep-alive timeis greater than the idle timeout setting configured for your load balancer.

According to Nginx documentation keep-alive timeout and keep-alive time both are different properties. https://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_time

It would be very helpful if configured with the example.

Configuration from Nginx:
  keepalive ??;
  keepalive_time ??;
  keepalive_timeout ??; 

Configuration from ELB:
  Idle timeout: ??

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .