PubSub between Web Browser and Command Line

I’m trying to write the simplest POC for PubSub using one node as command line IPFS and the other as Web app node.
The source code is available with simple breakdown:

  1. run-daemon.sh - run the command line daemon with pubsub experiment.
  2. sub.sh - subscribe to message on poc1 topoc.
  3. src/components/app.js - the main app code which start IPFS node and publish message.

What am I missing?

1 Like

I’ve followed the readme in js-ipfs/examples/exchange-files-in-browser/, specifically running ipfs config Addresses.Swarm "[\"/ip4/0.0.0.0/tcp/9999/ws\"]" --json on my command line daemon and adding

node.swarm.connect('/ip4/192.168.1.81/tcp/9999/ws/ipfs/<my-daemon-peer-id>', (err) => {
   console.log('err', err)
})   

and PubSub is working now.

It does raise the question - how can I use PubSub on nodes I don’t know in advance?