简体   繁体   中英

Timeouts on file uploads and downloads

In my company website, we allow users to upload orders by uploading an excel file. When this file is uploaded, the details are read, all the required orders are created and then a coloumn, with the required order ids is added to the users file and sent back to them.

The problem I am facing is a 504 Gateway timeout. I am not able to diagnose what exactly is causing the timeout.

We have a HA_PROXY load balancer and application servers using PHP.

How should I detect what is causing the timeout issue? Is it HA_PROXY, apache or the users browser?

PS: The return file to be sent to the user exists in the temp directory of PHP in the server but because the connection has timed out is not sent back to the user.

I'm pretty sure it is HA_PROXY .

Got that as well on our setup: the server still finishes what he is doing (so it is not the server, and set_time_limit(0) won't work), the user just doesn't get an answer anymore as it took the server longer than (I guess) HA_PROXY allows.

If it was the server, execution on the server itself would be cut short, your file wouldn't be completely uploaded.

If it was the browser, there would be differences when using another browser.

I don't know what to do about it though as I'm not the one maintaining our servers and we never looked into it, because it only happened for cron scripts which (unless debugging) don't have output anyway.

If you need sent back to the user at Real-time , You need add this code in the head of your file .

set_time_limit(0);

And from your description , I think you can use asynchronous processing .

When the file has been uploaded , You can response "Processing" to the User .

Then you can write a Ajax Request to another url to check the file is right for download , every 10 seconds .

stat.php?id=file_id

If it ready , you can redirect the page to the download , like:

down.php?id=file_id

set_time_limit(0)

这种方式可以增加文件上传时间

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM