user3081211
user3081211

Reputation: 1331

nginx infinite keepalive_requests

We continually poll our nginx server every 5 seconds, using keep-alive to hold the connection open.

By default keepalive_requests is set to 100, so after 100 requests on the keep-alive connection, nginx disconnects.

Currently we have set keepalive_requests to a very large number to solve this problem, however is there a way to make it infinite?

We want to hold the connection open indefinitely, regardless of how many requests are made on the same keep-alive connection. keepalive_timeout is enough for us.

Upvotes: 3

Views: 4402

Answers (1)

Allen Luce
Allen Luce

Reputation: 8389

Currently, the only way to do this is to modify the source. This is the relevant code within nginx:

if (r->keepalive) {
    if (clcf->keepalive_timeout == 0) {
        r->keepalive = 0;

    } else if (r->connection->requests >= clcf->keepalive_requests) {
        r->keepalive = 0;
    } else {...}

A value of 4294967295 for keepalive_requests corresponds to about 680 years of 5-second requests. If you need more than that, I'd recommend patching the code.

Upvotes: 3

Related Questions