I am currently building a custom monitoring tool that uses the Notification API to track active conversations. I am finding that our WebSocket connection for the notification channel is being dropped every few hours, and my tool is missing several minutes of data before it successfully reconnects. Is there a best practice for maintaining a persistent notification channel, and how can I detect a ‘Silent Disconnect’ where the WebSocket appears open but no events are being received?
Greetings. I am a digital channels specialist and I have spent a lot of time with the notification service. You should implement a ‘Heartbeat’ mechanism in your tool. Genesys Cloud sends a ping event every sixty seconds. If your tool does not receive a ping for more than ninety seconds, you should assume the connection is dead and trigger a reconnection. Also, remember that a notification channel has a ‘Time-to-Live’ of twenty-four hours. You must proactively create a new channel and migrate your subscriptions before the old one expires to avoid any data loss!
I want to add a note about ‘Channel Overlap’. To follow up on And96, the safest way to reconnect without losing data is to create your new WebSocket before you close the old one. This allows you to receive events on both channels for a few seconds. You can then deduplicate the events in your application based on the eventTime and the interactionId. It is the only way to ensure one hundred percent uptime for your monitoring tool!
I have seen these silent disconnects break many custom dashboards. Tar55, make sure you are also monitoring the v2.users.{id}.tokens.metadata endpoint. If your OAuth token expires, your notification channel will stop receiving events even if the WebSocket is still connected. Your tool should always refresh its token at least thirty minutes before it expires to maintain the authorization for the notification stream.