Search code examples
phpnginxhttp-headersconnectionkeep-alive

Nginx close keep-alive connection from php


Hello Everybody

I have trouble with nginx server . I have configured nginx with keep alive connection.

keepalive_timeout 65;

And connect to server with persistent connection , i send many request to server in same connection .

I want to close persistent connection from php. php exit and die command closes response , not connection . And client can resend to server request in same connection .

simply, i want to close persistent connection from php

I use this command ,

header('Connection:close');

But not affected , connection is still alive

How can close http connection from php


Solution

  • I took SO long to find the answer to this.

    In PHP you need to call:

    fastcgi_finish_request();