简体   繁体   中英

how to response to the server ping in tornado websocket


I have written a websocket server in tornado and i used websocket_ping_interval=60 to detect which connection is really closed after 60 sec. but after 60 sec the server disconnects the link(even if it's been disconnected). i think this is done because the server sends a ping packet each 60sec and the client doesn't response to the server. i want the client side(which is written in websocket python module) to response the server whenever the server sends ping req.
I have the same problem with client websocket in browsers. any idea how to solve it?

Tornado's websocket implementation handles pings automatically (and so do most other implementations). You shouldn't have to do anything.

Tornado's ping timeout defaults to 3 times the ping interval, so if you're getting cut off after 60 seconds instead of 180 seconds, something else is doing it. Some proxies have a 60-second timeout for idle connections, so if you're going through one of those you may need a shorter ping interval.

If that's not it, you'll need to provide more details, ideally a reproducible test setup with client and server code.

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