I have a client side that sends a request that requires a long processing time, the client sends the request in ajax. After the request is accepted on the server, the client is redirected to another page, this is done using fastcgi_finish_request (I run php-fpm)
LongWork.php:
<?php fastcgi_finish_request(); sleep(1000);
client.js:
$.ajax({ url: "...", data: {}, success: function() { top.location.href="next_page.php" } });
Ajax is dispatched, and a successful callback causes a redirect to next_page.php, as expected.
But then the page stops, and I get no service until the dream ends. It looks like my connection is waiting for the completion of the same php-fpm process
I am running nginx with php-fpm, any idea why this is happening?
EDIT :
After much research, I found that the reason for this behavior is that I have an active session (from the facebook SDK file) when I destroy a session on LongWork.php:
<?php session_destroy();
Can you think of this solution?
Should I do something different from session_destroy()
EDIT:
after Lachlan Pease comment, I switched session_destroy to session_write_close
source share