Skip to content
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

PubSub not recognizing subscribers/peers, when peers are subscribed to same topic. #2568

Closed
0xCourtney opened this issue May 28, 2024 · 2 comments
Labels
need/author-input Needs input from the original author

Comments

@0xCourtney
Copy link

0xCourtney commented May 28, 2024

  • Version:
"@chainsafe/libp2p-gossipsub": "^13.0.0",
"@chainsafe/libp2p-noise": "^15.0.0",
"@chainsafe/libp2p-yamux": "^6.0.2",
"@libp2p/bootstrap": "^10.0.24",
"@libp2p/floodsub": "^9.0.20",
"@libp2p/peer-id-factory": "^4.1.2",
"@libp2p/tcp": "^9.0.26",
"@libp2p/websockets": "^8.0.24",
"libp2p": "^1.6.0",
  • Platform: MacOS

  • Subsystem:

libp2p/connection-manager 
@libp2p/floodsub
@libp2p/pubsub
@chainsafe/libp2p-gossipsub

Severity: High

Description:

I've configured a node to connect to a known bootstrapped peer and broadcast messages using floodsub. Both nodes are running locally on my machine. It seems like the node can connect to the peer just fine (and vice versa) however pubsub does not seem to recognize that a peer is connected despite both nodes subscribing to the same topic. As a result, I cannot exchange messages between nodes. I was having this issue using gossipsub originally, and was only able to get gossipsub to work when I set the directPeers. I would expect that I could exchange messages between peers as long as they both subscribe to the same topic.

Looking into this a bit further it seems the issue may be with the connection managers onConnect method. I tried debugging the _onPeerConnected function but it was not being called. For reference, this may be related to ChainSafe/js-libp2p-gossipsub#481.

Logs
# Node 1 is started and subscribed to 'test-topic'
Qma3GsJmB47xYuyahPZPSadh1avvxfyYQwk8R3UnFrQ6aP - node instance has started
Qma3GsJmB47xYuyahPZPSadh1avvxfyYQwk8R3UnFrQ6aP - node is subscribed to test-topic

# Node 2 is started and subscribed to 'test-topic'
QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm - node instance has started
QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm - node is subscribed to test-topic

# Node 1 discovers Node 2
Qma3GsJmB47xYuyahPZPSadh1avvxfyYQwk8R3UnFrQ6aP - peer found: QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm

# Node 2 discovers Node 1
QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm - peer found: Qma3GsJmB47xYuyahPZPSadh1avvxfyYQwk8R3UnFrQ6aP

# Node 1 connects with Node 2
QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm - connected to: zQma3GsJmB47xYuyahPZPSadh1avvxfyYQwk8R3UnFrQ6aP

# Node 2 connects with Node 1
Qma3GsJmB47xYuyahPZPSadh1avvxfyYQwk8R3UnFrQ6aP - connected to: zQmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm
Qma3GsJmB47xYuyahPZPSadh1avvxfyYQwk8R3UnFrQ6aP - node peers QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm

# Node 1 does not have pubsub peers or subscribers
Qma3GsJmB47xYuyahPZPSadh1avvxfyYQwk8R3UnFrQ6aP - node connections 2
Qma3GsJmB47xYuyahPZPSadh1avvxfyYQwk8R3UnFrQ6aP - pubsub subscribers: 0
Qma3GsJmB47xYuyahPZPSadh1avvxfyYQwk8R3UnFrQ6aP - pubsub peers: 0

# Node 2 does not have pubsub peers or subscribers
QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm - node connections 2
QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm - pubsub subscribers: 0
QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm - pubsub peers: 0

Steps to reproduce the error:

Minimally reproducible example: https://gist.github.com/0xCourtney/c59b786d8609ebcba7747658f3b7b6d3

@0xCourtney 0xCourtney added the need/triage Needs initial labeling and prioritization label May 28, 2024
@achingbrain
Copy link
Member

Can you please configure the @libp2p/identify service and try again?

import { identify } from '@libp2p/identify'

const n = await createLibp2p({
  // ... other config
  services: {
    // ... other services
    identify: identify()
  }
})

@achingbrain achingbrain added need/author-input Needs input from the original author and removed need/triage Needs initial labeling and prioritization labels May 29, 2024
@0xCourtney
Copy link
Author

Can you please configure the @libp2p/identify service and try again?

import { identify } from '@libp2p/identify'

const n = await createLibp2p({
  // ... other config
  services: {
    // ... other services
    identify: identify()
  }
})

That did it, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/author-input Needs input from the original author
Projects
None yet
Development

No branches or pull requests

2 participants