How to handle external websockets?


Hey there! I’m quite new to microservices and Nameko. I hope someone can help me.
I’m trying to open multiple websocket clients that receive external datastreams. I want to be able to (at some point) maybe interact with a websocket (close it, change the subscription, send a message). But because the service that started the socket client doesn’t store a reference to the websocket object, I can’t do anything with it.

So my question is, how do I interact with that websocket if the services don’t know where it is? Should I store it somewhere? Make some kind of queue?


Can you post some example code? I’m not sure what you’re trying to achieve.

When you say websocket client, what do you mean exactly?


I’m sorry I wasn’t clear. I’ve learned since this post that I should write a DependencyProvider to keep states between workers. With websocket client I meant a websocket that primarily receives data as a listener.

I can’t really find anything in de docs on how DependencyProviders keep their state compared to the service itself. From my earlier experimentation I had the impression dependencies keep getting instantiated with every service call but maybe the provider itself behaves differently.