How to best renew a websocket for notifications in Python?

Hello.

I have a Python container that is constantly listening to Genesys notifications in a websocket, and recently I bumped into the 24 hour valid time limit for the websocket. I know that you can renew the channel by resubscribing the topics.

What is the best recommended practice for renewing the channel in an asynchronous python consumer? How to detect that the channel needs renewing, what action to take to renew, and in which part of the code flow in a consumer thats constantly listening? As a small guide, the following code is a simplified version of the consumer:

async def main():
async for websocket in websockets.connect(uri):
.......
while True:
notification_message = await websocket.recv()
.......

If you have any doubts, please ask. Thanks for the help.

An application would typically use some sort of timer or periodic process to check and see how long it's been since the channel was refreshed and determine if it needs to take action.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.