Open nikkolasg opened 5 years ago
Your scenario is valid. You need to wait a bit for overlay initialization (1-2s for the heartbeat).
Great, indeed it works when I put 2 seconds, thanks ! I'm working on a commented version now.
Also there's still one weird behavior I would not have expected: if I connect the nodes together before creating the pubsub and subscribing to the topic, it does not work - simply hangs. Connecting the nodes after subscribing works....
the delay should fix this weird behaviour too.
Note that if you open the connections before creating the PubSub
object, then it will not work as there will be no connection notification events and so the peers will not be discovered.
@nikkolasg this is a nice example and something that others have requested (https://github.com/libp2p/go-libp2p-pubsub/issues/160 & https://github.com/libp2p/go-libp2p-pubsub/issues/235), mind if I take it to add it to the repo?
Hi, I wanted to play with pubsub a bit, with a very basic scenario:
I would expect that peer 2 would receive the message and also transmit it to peer 3 but in my code only peer 2 does.
I fail to find the relevant missing piece of info in the library... Is my scenario a valid one or is this expected to fail according to the specs ? And if it is a valid one, would you know why it does not work with my code below ?
I'd be happy to add lots of comments and make a PR to show such a basic example.
PS: I added the
DisableRelay
option since otherwise that does not work, as shown in the issue https://github.com/libp2p/go-libp2p-examples/issues/21