我有一个 python web worker,它根据客户请求流式传输一个大文件。 30 秒后连接被 Heroku 终止。我正在使用 web.py
并产生新的输出。根据 Heroku 文档:
Cedar supports HTTP 1.1 features such as long-polling and streaming responses. An application has an initial 30 second window to respond with a single byte back to the client. However, each byte transmitted thereafter (either received from the client or sent by your application) resets a rolling 55 second window. If no data is sent during the 55 second window, the connection will be terminated.
我每 55 秒发送超过 1 个字节,但连接仍然终止。
这些是我正在使用的 header
web.header('Content-type' , 'application/zip')
web.header('Content-Disposition', 'attachment; filename="images.zip"')
我什至尝试添加:
web.header('Transfer-Encoding','chunked')
我做错了什么吗?
最佳答案
问题似乎是错误的 gunicorn
设置造成的。在 Procfile
中延长 gunicron
超时就达到了目的:
--timeout 300
关于python - 30 秒超时后,从 Heroku 流式传输大文件失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17609342/