Unable to connect 2 js-ipfs nodes using webrtc-star in Swarm (but browser does connect)

I’m trying to connect two js-ipfs nodes by connecting both to a libp2p webrtc star exclusively.

Both nodes appear to be connected with the webrtc star, but aren’t connecting with each other.

Only when I open a js-ipfs session in my browser, then it establishes a connection with both nodes (but the nodes don’t seem to connect with each other directly).

Here’s my setup:

  1. I created a WebRTC star node by following these instructions.

  2. I have two separate servers each running the following js-ipfs instance:

const initIPFSInstance = async () => {
  return await IPFS.create({
    repo: './.ipfs',
    relay: { enabled: true, hop: { enabled: true } },
    EXPERIMENTAL: { pubsub: true },
    config: {
      Addresses: {
        Swarm: [
          "/dns4/my-webrtc-star.herokuapp.com/tcp/443/wss/p2p-webrtc-star/",
        ]
      }
    },
    libp2p: {
      modules: {
        transport: [WebRTCStar]
      },
      config: {
        peerDiscovery: {
          webRTCStar: { 
            enabled: true
          }
        },
        transport: {
          WebRTCStar: { 
            wrtc
          }
        }
      }
    }
  });
};

Running the nodes I get:

Swarm listening on /dns4/my-webrtc-star.herokuapp.com/tcp/443/wss/p2p-webrtc-star/p2p/12D3KooWR5U7wyqFaBexxxxxxxxxxxxxxxxxyunS2pZUPqR3DAbg

The nodes never sync with each other directly and only seem to connect to browser clients (that also only connect to the WebRTC star).

How do I fix this?

Fixed . Only needed to add Websockets as a transport and add the websocket IP (/ip4/0.0.0.0/tcp/4003/ws) to the nodes’ Swarm list.

I think that the js-ipfs nodes cannot communicate between each other over the webrtc without browser nodes with circuit relay enabled

When you open your brower session indeed you should see your two nodes communicating over the relay node

(that is my understanding)