How to make PHP flush() work on Azure web apps?

RONALDO RADUNZ 41 Reputation points
2021-10-05T18:19:17.157+00:00

This simple script will run without a problem on a LAMP server (Ubuntu) running on a VM/Azure. However, when ported to Azure web apps (php), the same script will get a 502 or 504 error after 5 minutes, and will show no output. If the number of lines is reduced to less than 300 (about 5 minutes time) it will run, but all lines will appear only when the script ends. Any thoughts?
137848-code.png

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,961 questions
0 comments No comments
{count} votes

Accepted answer
  1. Takahito Iwasa 4,841 Reputation points MVP
    2021-10-05T19:54:22.997+00:00

    Hi.

    You're probably running on PHP8, so Nginx's default settings make this work.

    I tried changing the buffering mode and it worked, so I've posted the steps in the entry below.

    https://dev.classmethod.jp/articles/app-service-on-linux-php-flush-buffering/

    try it.
    Also, I think you should review the timeout value at the beginning from the viewpoint of the Nginx setting value.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful