Disconnecting the WebSocket
WebSockets are designed to stay open for the life of the oAuth token (60 minutes). 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).
- Accept and process events that are in the process of being sent.
- Wait for OHIP to close the connection.
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 5000 ms (5 seconds) between sending the "Complete" message to close a WebSocket connection and sending the next "Subscribe" message to reopen a WebSocket connection.
Parent topic: Connecting to the Streaming API