3
votes

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

2
your question is not clear, what is the error ? - user1376704
I connect to server from cliend and send request and php run this code. header('Connection:close'); But this php code not close connection , the connection is still alive . I am using persistent connection from client to server - Taleh Ibrahimli
can you show us the nginx config, the php code and php-fpm config (since you are using nginx I guess you are also using php-fpm) - user1376704

2 Answers

7
votes

I took SO long to find the answer to this.

In PHP you need to call:

fastcgi_finish_request();
1
votes

From this servfault answer it seems you can try it by allowing this header in the nginx fastcgi handler.

fastcgi_pass_header Connection-close;