I have an Python Tornado app hosted at Heroku. It serves WebSocket connections and I want them to be kept alive for a long time (two hours). However, due to Heroku's limitations, it terminates the connection after 55 seconds since the last byte received.
Possible solutions could be:
Connection: Keep-Alive
header in WebSocket requests Here's some code for reference.
This is the client part where the connection gets established:
req = HTTPRequest('server_url',
headers={'Connection': 'Keep-Alive'})
self.conn = await websocket_connect(req, io_loop = self.ioloop)
And this is the Heroku log message:
at=error code=H15 desc="Idle connection" method=GET path="/"
host='app_url' request_id=some_id fwd="ip_address"
dyno=web.1 connect=0ms service=55003ms status=503 bytes=
How can I keep the connections alive?
正如他们关于 Websockets 的文档所述,保持活动数据包实际上是 Heroku 上 Websockets 的唯一解决方案。
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.