libp2p / js-libp2p-webrtc-star

libp2p WebRTC transport that includes a discovery mechanism provided by the signalling-star
https://libp2p.io
Other
320 stars 96 forks source link

It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client #287

Closed tabcat closed 3 years ago

tabcat commented 3 years ago

Unable to connect to public webrtc-star signal servers in what seems due to a webrtc-star patch upgrading socket.io-client.

experienced after running npm run test on https://github.com/orbitdb/orbit-db-store/tree/0330c952ff8b54d7d9ccf5248a32dab4642a01d3

will try running the rendezvous server locally.

error from ipfs

Error: Transport (WebRTCStar) could not listen on any available address
    at c.listen (bundle.js:48:265773)
    at async C._onStarting (bundle.js:99:112605)
    at async C.start (bundle.js:99:110516)
    at async file:///home/anders/Documents/dev/github/orbit-db-store/test/browser/bundle.js:429:133957
    at async e.exports.start (bundle.js:85:314661)
    at async e.exports.spawn (bundle.js:85:298950)

relevant ipfs config

EXPERIMENTAL: {
      pubsub: true
    },
    config: {
      Addresses: {
        Swarm: ['/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star'],
      }
    }
}

js-libp2p src/transport-manager.js#L143-L172

async listen () {
    const addrs = this.libp2p.addressManager.getListenAddrs()

    if (addrs.length === 0) {
      log('no addresses were provided for listening, this node is dial only')
      return
    }

    const couldNotListen = []
    for (const [key, transport] of this._transports.entries()) {
      const supportedAddrs = transport.filter(addrs)
      const tasks = []

      // For each supported multiaddr, create a listener
      for (const addr of supportedAddrs) {
        log('creating listener for %s on %s', key, addr)
        const listener = transport.createListener(this._listenerOptions.get(key), this.onConnection)
        this._listeners.get(key).push(listener)

        // We need to attempt to listen on everything
        tasks.push(listener.listen(addr))
      }

      // Keep track of transports we had no addresses for
      if (tasks.length === 0) {
        couldNotListen.push(key)
        continue
      }

      const results = await pSettle(tasks)

here addrs is an array of 1 webrtc-star multiaddr from the config results is an array of 1 object:

{
  isFulfilled: false,
  isRejected: true,
  reason: "Error: It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"
}
vasco-santos commented 3 years ago

Thanks for reporting this. I am going to revert the commit and ask for the server to be updated.

vasco-santos commented 3 years ago

I released 0.20.5 with the commit reverted.

@mburns can I have your help here? I was expecting the deployed webrtc-star servers to be updated on push, which is not the case, so we will need to update them. However, from this issue I noticed that v2 clients will not be able to talk with v3 servers 😞

I did a small research and it seems the best way would be do to

have both a group of v2 servers and v3 servers in parallel,
and route the traffic based on the EIO query parameter (EIO=3 for Socket.IO v2, EIO=4 for Socket.IO v3)

per https://socket.io/docs/v3/migrating-from-2-x-to-3-0/index.html#How-to-upgrade-an-existing-production-deployment

What do you think? Is this feasible on your side? The v3 server was released in v0.20.4

tabcat commented 3 years ago

Thank you @vasco-santos everything is working great now :+1:

Running the latest rendezvous server locally had worked for me in the mean time as well

vasco-santos commented 3 years ago

Thanks for the alert/feedback @tabcat I will be looking on an upgrade for this with the infra team

vasco-santos commented 3 years ago

FYI #292 aims to solve this