I’m trying to use the ConnectionManager Notifee to handle certain events when a new connection occurs. My current progress shows that the ConnectedF method of the notifee is called, but I am having a difficult time communicating on a stream with the peer within this method. The peer never receives the messages sent along the stream and therefore never responds.
More specifically, I’m trying to build out the following workflow for two libp2p clients:
When connecting to a new peer, exchange a message to that peer, and conditionally disconnect from that peer based on the contents of the message.
Example flow of events in my mind:
- ClientA may have discovered ClientB in a DHT
- ClientA dials ClientB
- On connection, open a stream with ClientB on protocol “/v1/example”
- ClientB has a stream handler for “/v1/example”
- ClientA sends a message on the stream and ClientB responds
The problem I am having is on the final step. ClientB is not receiving this message in their stream handler.
If you’d like to see the code to understand it, I have a work in progress PR here: https://github.com/prysmaticlabs/prysm/pull/2306