Keeping the Stream Open

To keep the connection open, you must send a "ping" request at least every 15 seconds on the WebSocket (see the below JSON example). 

{"type":"ping"}

Note:

You are not charged for this "ping" request.

An example implementation is listed on GitHub in the Recipes section under ‘Client usage with ping/pong timeout and latency metrics.’

The server also sends pings to the client.  It is important that as soon as it receives a "ping" from the server the client return a "pong" message to this request from the client as documented in the Protocol:

{"type":"pong"}

Updating Authentication

The streaming API is secured by an oAuth token whose life is limited to one hour (sixty minutes). To continue receiving events, you must keep the stream open by doing the following:
  1. Close the WebSocket (see Disconnecting the WebSocket for more information).
  2. Request a new oAuth token from the oAuth API.
  3. Reopen the websocket and specify the new "access_token" received from the oAuth API.