title: How to ping websocket server, so it doesn't disconnect me for being idle
body: <p>I'm using <a href="https://pypi.python.org/pypi/websocket-client" rel="noreferrer">websocket-client</a> to connect to a websocket server.  The server i'm connected to seems to be expecting me to ping it periodically or else it disconnects me. </p>
  
  <p>Right when I connect to the server, it sends me this message:</p>
  
  <pre><code>0{"sid":"SomeID","upgrades":[],"pingInterval":25000,"pingTimeout":60000}
  </code></pre>
  
  <p>This seems to tell me the ping interval and ping timeout.  I noticed that my websocket client is getting disconnected consistently ~1 minute and 25 seconds after I connect.  And if you add up those numbers 60s + 25s you get 1 min and 25 seconds.  So It seems I need to ping this server every so often so it doesn't disconnect me.  </p>
  
  <p>How do I ping the server?  I tried ws.ping() but that didn't seem to exist.  Do I need to send data to the server in some format it's expecting?  Or is there some built in ping command?</p>
  
  <pre><code>    websocket.enableTrace(True)
      ws = websocket.WebSocketApp("wss://socket.serverssite.com/socket.io/?transport=websocket",
                                  on_message=on_message,
                                  on_error=on_error,
                                  on_close=on_close)
      ws.run_forever()
  </code></pre>
  
  <p>Note: I made a websocket client in node (not python) and it doesn't get closed after 1 min 25 seconds.  So It seems that has some built in ping that this python websocket client does not...</p>
  
  <p><strong>------------------------Edit-------------------------</strong></p>
  
  <p>Tried setting ping_interval and ping_timeout, but it's still closing:</p>
  
  <p>2017-11-06 12:49:14.340037--------------------- Doing stuff</p>
  
  <p>2017-11-06 12:49:14.340309--------------------- Doing stuff</p>
  
  <p>send: '\x89\x80\\xd9\xc4\xdd' </p>
  
  <p>2017-11-06 12:49:19.341680--------------------- Doing stuff</p>
  
  <p>2017-11-06 12:49:19.341958--------------------- Doing stuff</p>
  
  <p>send: '\x89\x80\xd9\x06\xef\xa8' </p>
  
  <p>2017-11-06 12:49:24.343426--------------------- Doing stuff</p>
  
  <p>2017-11-06 12:49:24.343769--------------------- Doing stuff</p>
  
  <p>send: "\x89\x80\xe6\x92'\xb8" </p>
  
  <p>send: '\x88\x823\xfb$\xd10\x13' </p>
  
  <p>closed (Here is where the closed method gets called, the server shut me down)</p>