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
{{ message }}
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
I cannot get PubSub to work with js-ipfs, even with recommended settings.
Whether they run in the browser in different tabs, or through node.js inside my ava tests, the IPFS nodes I spawn will simply not send messages to each other, even when they're subscribed to the same topic, running on the same machine, and connected to the ws-star node.
Nodes will only receive their own messages.
This might not be related, but I've also noticed that IPNS names published by one node will not be resolved by another, even on the same machine.
Only if I spawn a node using the same repo as the node that created the IPNS name, does the name resolve.
Publishing files however appears to work perfectly, in browser or outside.
Steps to reproduce the error:
I originally found this issue in the browser, but here is some simplified code from my tests (using ava) which reproduces the problem: ipfs-utils.js:
import{mount}from'@vue/test-utils'importtestfrom'ava'import{init,makeBuffer}from'../../util/ipfs-utils.js'test.serial('Pubsub',async(t)=>{constipfs=awaitinit('repo/'+Date.now())constipfs_1=awaitinit('repo/1'+Date.now())consttopic='Topic'+Date.now()awaitipfs.pubsub.subscribe(topic,(msg)=>console.log(msg))console.log(`IPFS_0: subscribed to ${topic}`)awaitipfs_1.pubsub.subscribe(topic,(msg)=>console.log(msg))console.log(`IPFS_1: subscribed to ${topic}`)awaitipfs.pubsub.publish(topic,makeBuffer({time: Date.now()}))varpeers_0=awaitipfs.pubsub.peers(topic)varpeers_1=awaitipfs_1.pubsub.peers(topic)console.log(peers_0,peers_1)t.is(peers_0.length>0,true,"Peers are connected to 0")t.is(peers_1.length>0,true,"Peers are connected to 1")t.pass()})
Test fails because peers_0 is an empty list.
The first node receives its own message. but the second doesn't receive it.
The text was updated successfully, but these errors were encountered:
As for the IPNS issue, I've also created a test to replicate that:
test.serial('IPNS',async(t)=>{constipfs=awaitinit('repo/'+Date.now())constipfs_1=awaitinit('repo/1'+Date.now())constcid="/ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG"constrecord=awaitipfs.name.publish(cid)constres_0=awaitipfs.name.resolve(record.name)constres_1=awaitipfs_1.name.resolve(record.name)t.is(res_0.path,cid,"Name resolves on same node")t.is(res_1.path,cid,"Name resolves on other node")t.pass()})
This fails because the second resolve raises an exception:
Rejectedpromisereturnedbytest.Reason:
Error{code: 'ERR_NO_RECORD_FOUND',message: 'record requested was not found for QmXyTFHzdDDaLZPshCpWsLVw1PpVTvVY9RRKyWg12pnEex (/ipns/ �&�9�f\\H╚4�H��$/���_���L���) in the network',}
To receive messages over pubsub your nodes either need to be connected directly to each other or connected to another node that is also subscribed to the topic.
Please either wait for the two nodes to discover one another over the rendezvous (use swarm.peers to check) or connect them directly with swarm.connect and then send your pubsub message.
If you're still having issues then please comment here again and i'll re-open.
Note - There's a pubsub interop issue that is currently being fixed, this might also be a contributing factor.
Type: Bug
Severity: High
Description:
I cannot get PubSub to work with js-ipfs, even with recommended settings.
Whether they run in the browser in different tabs, or through node.js inside my ava tests, the IPFS nodes I spawn will simply not send messages to each other, even when they're subscribed to the same topic, running on the same machine, and connected to the ws-star node.
Nodes will only receive their own messages.
This might not be related, but I've also noticed that IPNS names published by one node will not be resolved by another, even on the same machine.
Only if I spawn a node using the same repo as the node that created the IPNS name, does the name resolve.
Publishing files however appears to work perfectly, in browser or outside.
Steps to reproduce the error:
I originally found this issue in the browser, but here is some simplified code from my tests (using ava) which reproduces the problem:
ipfs-utils.js
:Test:
Test fails because peers_0 is an empty list.
The first node receives its own message. but the second doesn't receive it.
The text was updated successfully, but these errors were encountered: