Iāve been following this tutorial
I think Iām doing everything right.
The ipfs nodes are getting created and logging the following message:
IPFS node ready with address QmX7qsqNew4qcJrzeDJ7QJrkuanvikr9MXKoe1J6i4YdMc
But Iām not seeing any messages logged to the console in response to the āpeer joinā and āpeer leftā events
Without errors itās hard to figure out where Iām going wrong. Iāve pasted the code below and then details about my environment in case someone has an idea about whatās going wrong.
const IPFS = require('ipfs')
const Room = require('ipfs-pubsub-room')
const ipfs = new IPFS({
repo: repo(),
EXPERIMENTAL: {
pubsub: true
}
})
ipfs.once('ready', () => ipfs.id((err, info) => {
if (err) {throw err}
console.log("IPFS node ready with address " + info.id)
}))
const room = Room(ipfs, 'ipfs-pubsub-demo');
//console.log("ipfs", ipfs)
//console.log("room", room)
room.on("peer join", (peer) => console.log('peer' + peer + 'joined'))
room.on("peer left", (peer) => console.log('peer' + peer + 'left'))
// send and receive
room.on("peer joined", (peer) => room.sendTo(peer, 'Hello ' + peer + '!'))
room.on("message", (message) => console.log('got message from ' + message.from + ': ' + message.data.toString()))
function repo (){
return 'ipfs/pubsub-demo/' + Math.random()
}
Iām running node v9.4.0
And here is my json package.json
{
"name": "ipfs-pubsub-demo",
"version": "0.0.1",
"description": "IPFS pub-sub demo",
"main": "index.js",
"scripts": {
"compile": "browserify src/app.js -o public/js/app.js -d",
"start": "http-server -c-1 -p 12345 public"
},
"author": "jeff following pedro",
"license": "MIT",
"dependencies": {
"browserify": "^16.2.2",
"http-server": "^0.11.1",
"ipfs": "^0.28.2",
"ipfs-pubsub-room": "^1.2.1"
}
}