A J Brockberg
A J Brockberg

Reputation: 613

implementation of ping/pong for tornado websocket

I have a websocket client in python implemented using tornado.websocket. WebSocketClientConnection which connects to a server at remote end and communicate over websocket. Earlier I had implemented the ping/pong like feedback mechanism at application layer to ensure if the remote endpoint is still responsive.

I just recently updated my tornado package and I came across the ping_interval in WebSocketClientConnection. I removed the old ping/pong mechanism at application layer and added this ping_interval in my implementation.

After this updates the websocket is getting closed after the mentioned ping_interval timeout. The server at remote end handles the ping at transport layer and respond accrodingly.

  1. currently I have not implemented the ping method so should I have to implement ping method for WebSocketClientConnection?,
  2. should I have to send any data in ping method?
  3. do I have to implement any method to handle the response send by remote server for the ping request?

Upvotes: 6

Views: 1635

Answers (1)

Fine
Fine

Reputation: 2154

  1. No, It's implemented by default.
  2. You may but don't have to.
  3. I assume that by response you've ment pong. If you're using ping_interval you don't have to process pong, but if you're sending pings manually you have to control timeouts by yourself so you have to process pongs by implementing tornado.websocket.WebSocketClientConnection.on_pong method.

Upvotes: 6

Related Questions