Help with ipfs-pubsub-room

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"
  }
}

hi,

you need to be sure your ipfs node is started so try that :

ipfs.on(ā€˜readyā€™, () => {
const room = Room(ipfs, ā€˜room-nameā€™)

room.on(ā€˜peer joinedā€™, (peer) => {
console.log(ā€˜Peer joined the roomā€™, peer)
})

room.on(ā€˜peer leftā€™, (peer) => {
console.log(ā€˜Peer leftā€¦ā€™, peer)
})

// now started to listen to room
room.on(ā€˜subscribedā€™, () => {
console.log(ā€˜Now connected!ā€™)
})
})