If you try to open a new websocket to a subscription that has been terminated (e.g. trying to reconnect a chat), it might get immediately closed by PureCloud, e.g. if conversation have already been terminated, if some data was faulty, etc.
We get a reason and a code back. E.g.
1001 - "The conversation is ended"
4100 - "Error connecting to conversation (8e5da88a-1260-4dfa-a52f-2a7ad4bb1620)"
I cannot find any documentation on the codes. Is there a reference somewhere or can it be produced?
Hey Joel. In your case, I would recommend against trying to make programmatic decisions based on the websocket return code. All of your decisions should be based on information from the HTTPS guest API, or information contained within websocket events. The error codes in the web socket aren't meant to be significant, and hence they're not documented.
Okay, then we would reconnect to the chat, then check if the guest member's state is CONNECTED or DISCONNECTED, then proceed to close the websocket if the state is DISCONNECTED (unless the websocket was already auto-closed by PureCloud, I have seen that happening).
We will assume that reconnect will succeed if guest member's state was CONNECTED (if we did the reconnect right), and threat other cases as unrecoverable/terminating the chat.