-
Notifications
You must be signed in to change notification settings - Fork 445
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 Working on Relayed Connections without Relay Subscription in [email protected] #2349
Comments
bumping this |
Relayed connections are time/data limited which means they can be closed at any time so data-heavy protocols don't run over them by default. This is normally overridable with a Once that's been merged & released you should be able to configure it as: import { createLibp2p } from 'libp2p'
import { gossipsub } from '@libp2p/gossipsub'
const node = await createLibp2({
// other config
services: {
pubsub: gossipsub({
runOnTransientConnection: true
})
}
}) What's happening in your example is the pubsub message is being sent from What you want is for the message to got from With the |
This should resolve the issue, please re-open this issue if you're still having trouble getting it working. |
Version:
Platform:
Subsystem:
Severity:
Description:
After migrating from [email protected] to [email protected], I encountered an issue with pubsub on circuit-relayed connections. Previously, pubsub worked seamlessly on relayed connections, but in the newer version, pubsub on relayed connections fails unless the relay node itself subscribes to the same topic. This issue was not present in the earlier versions of libp2p.
Steps to reproduce the error:
https://gist.github.com/vaibhavmuchandi/7cc3d28161ceff68de9bb036bf03a24d
The script initializes a relay server and two libp2p nodes.
Node1 subscribes to a topic named "test-topic" and listens for messages.
Once Node2 connects to Node1, it publishes a message to the "test-topic".
In the current setup, you should see the published message logged in the console by Node1.
Now, comment out the line node.services.pubsub.subscribe("test-topic") in the createRelayServer function. This simulates the
relay not subscribing to the topic.
Rerun the script
Observe that Node1 no longer receives the published message from Node2, demonstrating the issue.
Expected Behavior:
Pubsub should work on relayed connections without the relay needing to subscribe to the topic, as it did in previous versions of libp2p.
Actual Behavior:
Pubsub on relayed connections only works if the relay server also subscribes to the pubsub topic.
The text was updated successfully, but these errors were encountered: