Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fastcgi_finish_request() undefined?

Tags:

php

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???

like image 786
whitwhoa Avatar asked Jun 26 '26 04:06

whitwhoa


2 Answers

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 :)

like image 116
whitwhoa Avatar answered Jun 27 '26 18:06

whitwhoa


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!

like image 23
Swiss Mister Avatar answered Jun 27 '26 18:06

Swiss Mister



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!