whitwhoa
whitwhoa

Reputation: 2489

fastcgi_finish_request() undefined?

I have nginx setup with php-fpm on my server and am attempting to use fastcgi_finish_request() however I receive message: PHP Fatal error: Call to undefined function fastcgi_finish_request()?

Is there something extra that I need to install on the server before this function is available? I've been digging around trying to find a solution and apparently haven't found the right keyword combination yet, or am highly confused about something???

Upvotes: 3

Views: 8793

Answers (2)

Swiss Mister
Swiss Mister

Reputation: 3394

This is an old question, but it showed up when I looked for
"Call to undefined function fastcgi_finish_request".
That's why I add what I found out here.

This script throws the error:

<?php
$now = date('Y-m-d H:i:s');
echo 'hello: ' . $now;
ignore_user_abort(true);
session_write_close();
fastcgi_finish_request();

sleep(10);
file_put_contents('test'.time().'txt', 'hello again: ' . date('Y-m-d H:i:s'));

But this does not:

<?php
header('Content-type: text/plain', true);
$now = date('Y-m-d H:i:s');
echo 'hello: ' . $now;
ignore_user_abort(true);
session_write_close();
fastcgi_finish_request();

sleep(10);
file_put_contents('test'.time().'txt', 'hello again: ' . date('Y-m-d H:i:s'));

So for some reason my PHP 7.4 FPM through Apache wants a header (example: header('Content-type: text/plain', true);) to be sent first...

Explanations are welcome!

Upvotes: 1

whitwhoa
whitwhoa

Reputation: 2489

The reason I was receiving the "PHP Fatal Error" message was because I was calling the fastcgi_finish_request() method from a script that was not being executing through fastcgi. After researching this I now have a better understanding of php-fpm...so that's a plus :)

Upvotes: 7

Related Questions