Tuesday, 3 May 2022

python websocket pub-sub with re-publish/broadcast

I would like to set-up a server that can subscribe to an external stream over a websocket (ws_ext) and then republish that data (after curating) to internal clients connecting to this server over websockets (ws_int).

My approach so far is to set up a fastapi server that can open websockets (ws_int) with internal clients . However, I don't understand how to have a listener embedded in this server that can listen to external stream and then publish to these internal clients in a non blocking way.

Can someone point me to a working example that can help?

Here is what i would like to achieve:

enter image description here

p.s: I HAVE BEEN able to make it work by decoupling broadcaster from subscriber using redis pubsub. So, what i have now setup is a client that listens to external stream, curate and pushes it to redis pubsub. then i have a separate broadcaster that listens to redis pubsub and pushes it out to clients after curating on its websockets. I would still love to combine these two without using redis or some such backend.



from python websocket pub-sub with re-publish/broadcast

No comments:

Post a Comment