Streaming large file from Heroku fails after 30 se

2019-02-24 09:40发布

I have a python web worker that streams a large file upon client request. After 30 seconds the connection is terminated by Heroku. I'm using web.py and yielding new output. According to Heroku docs:

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.

I send much more than 1 byte every 55 seconds but the connection is still terminated.

These are the headers I'm using

web.header('Content-type' , 'application/zip')
web.header('Content-Disposition', 'attachment; filename="images.zip"')

I even tried adding:

web.header('Transfer-Encoding','chunked')

Am I doing something wrong?

1条回答
该账号已被封号
2楼-- · 2019-02-24 10:07

It appears the problem was a result of bad gunicorn settings. Extending gunicron timeout in Procfile did the trick:

--timeout 300
查看更多
登录 后发表回答