-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Support multiple websocket connections in nym-client #3610
Comments
Hey! Can you elaborate a bit more about the "advanced use" you have in mind? Because it should be the case that a single application wanting to use the mixnet should connect to a single instance of a |
The case is implementing a client and a server using a familiar API in Rust. For example in the way you have By allowing multiple websocket connections (and with multiple I mean that I implement such a concept library so you can actually see how it is useful: https://github.com/parazyd/nym-dumpster/ |
@jstuczyn Any feedback on this? |
Yes, sorry. I've been pondering about this one, and I'm not entirely convinced whether broadcasting received messages to all websocket connections would be the best idea. While it might work for your use case, other people might get extremely confused. Say somebody connected two different applications to the same underlying client, for example a chat client and a crypto wallet (because in principle there would be nothing preventing them from doing so). They'd probably expect to only receive relevant messages back - the chat might get confused if it received some transaction results. So we'd most likely need to implement some form of multiplexing and message tagging to figure out what goes where. But that's most likely part of a bigger discussion. |
This can potentially be done by generating some kind of ID (or UUID) upon initial connection to nym-client, and then you tag that specific socket internally in nym-client, which will essentially become the router for websocket clients in that case. I think it can even be done without websocket clients actually having to care about it. Just as an abstraction over the websocket server, some kind of minimal router can be implemented based on the TCP sockets. |
To me it sounds like how it's done in nym-socks5-client with connection_id? |
Any news on this? |
Currently,
nym-client
only ever allows a single WebSocket connectionat a time. This is far from convenient for any type of advanced use.
To implement this, it should be possible to detach a task for every
TCP accept that happens in
listener.rs
. The code could then simplycopy all messages it has to all active listeners so every websocket
client can see the same messages that are being propagated.
This feature would allow multiple API clients to use the websockets
API concurrently and would greatly improve developer experience and
code performance when multiple active websocket connections are
necessary.
The text was updated successfully, but these errors were encountered: