Disconnecting the WebSocket

WebSockets are designed to stay open. When planning to disconnect from a WebSocket (refer to the Broken Connections topic), be aware of the following:
  • Events will queue up while disconnected, but only 7 days of events are retained. This can be a large volume of events, so before reconnecting, verify your consuming architecture can support the volume.

  • Send the "Complete" message (see the example below).

Sending the Complete Message

Before disconnecting, ensure you send the below Complete message (see the protocol for more information):
{
    "id": "<GUID>",
    "type": "complete"
}
You must send the Complete message to connect to the stream (identified by the application key, URL, and chainCode). Failure to send the Complete message will make it impossible to connect to the stream. If a subscribe message is sent to a stream that has not yet received a complete message, a 4409 error will occur.

Reconnecting after Complete

Ensure there is a minimum of 500 ms between sending the "Complete" message to close a WebSocket connection and sending the next "Subscribe" message to reopen a WebSocket connection.