You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all! 👋 I've been playing around with rust-libp2p recently, I wrote a simple application that discovers peers in the local network with mdns and then sends a simple JSON message using request-response. Technically, everything works fine, but I want to support multiple transports and this is the part that complicates it for me.
When my peer listens on multiple multiaddresses, it naturally sends all of them during the mDNS discovery phase. This means that in the mdns::Event::Discovered I get a list containing multiple entries for the same peer id. I then propagate these with Swarm::add_peer_address to my behaviours, so later I can call request_response::Behaviour::send_request to send my message to the selected peer. send_request takes only a peer id as an argument, so I can't specify which transport I want to use for this operation, which results in the message being sent multiple times to all the multiaddresses stored for the peer id.
Ideally, I'd like to specify an order of transports to try for communication, so only one is tried at a time and the next is used only as a fallback in case the first one didn't work. Is it somehow supported and I just missed it? Is it specific to this protocol only? Or should I rather handle the dialing myself to make sure only one transport is used to establish a connection with the peer?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi all! 👋 I've been playing around with
rust-libp2p
recently, I wrote a simple application that discovers peers in the local network withmdns
and then sends a simple JSON message usingrequest-response
. Technically, everything works fine, but I want to support multiple transports and this is the part that complicates it for me.When my peer listens on multiple multiaddresses, it naturally sends all of them during the mDNS discovery phase. This means that in the
mdns::Event::Discovered
I get a list containing multiple entries for the same peer id. I then propagate these withSwarm::add_peer_address
to my behaviours, so later I can callrequest_response::Behaviour::send_request
to send my message to the selected peer.send_request
takes only a peer id as an argument, so I can't specify which transport I want to use for this operation, which results in the message being sent multiple times to all the multiaddresses stored for the peer id.Ideally, I'd like to specify an order of transports to try for communication, so only one is tried at a time and the next is used only as a fallback in case the first one didn't work. Is it somehow supported and I just missed it? Is it specific to this protocol only? Or should I rather handle the dialing myself to make sure only one transport is used to establish a connection with the peer?
Beta Was this translation helpful? Give feedback.
All reactions