ipfs-pubsub-room icon indicating copy to clipboard operation
ipfs-pubsub-room copied to clipboard

HTTPS clients can't discover each other, but can discover and be discovered by HTTP-only clients

Open ccashwell opened this issue 7 years ago • 4 comments
trafficstars

This demo code doesn't seem to work once pushed behind an HTTPS endpoint. Specifically, HTTPS clients are communicating with the signaling server, but they're never made aware of one another. HTTP-only clients don't have this issue, and the interesting part is that an HTTP-only client can also discover and be discovered by HTTPS clients. There's just the disconnect between HTTPS clients and other HTTPS clients.

I thought maybe it was the signaling server, so I deployed my own libp2p-websocket-star rendezvous server to no avail. Am I missing something?

ccashwell avatar Mar 01 '18 00:03 ccashwell

After communicating with the libp2p team a bit more, I'm unsure where in the IPFS/libp2p stack this is occurring. The following is a simplified version of the code I'm using to test ipfs-pubsub-room:

import IPFS from 'ipfs'
import Room from 'ipfs-pubsub-room'

(() => {
  this.ipfs = new IPFS({
      EXPERIMENTAL: { pubsub: true },
      repo: `ipfs/mythereum/${Math.random()}`,
      config: {
        Addresses: {
          Swarm: [
            // note: I've also tried replacing these with a self-hosted rendezvous, same issue
            // whether it's my self-hosted server or any of the hosted ones I've discovered
            '/dnsaddr/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star',
            '/dnsaddr/ws-star-signal-1.servep2p.com/tcp/443/wss/p2p-websocket-star',
            '/dnsaddr/ws-star-signal-2.servep2p.com/tcp/443/wss/p2p-websocket-star',
            '/dnsaddr/ws-star-signal-3.servep2p.com/tcp/443/wss/p2p-websocket-star'
          ]
        }
      }
    })

    // IPFS node is ready, so we can start using ipfs-pubsub-room
    this.ipfs.on('ready', () => {
      this.ipfs.id((err, info) => {
        if (err) { throw err }
        console.log("Connected to IPFS as " + info.id)
      })

      this.gameLobby = Room(this.ipfs, 'game-lobby-079a4d')

      this.gameLobby.on('peer joined', (peer) => {
        let event = { event: "peer_joined", id: peer }
        console.log(JSON.stringify(event))
      })

      this.gameLobby.on('peer left', (peer) => {
        let event = { event: "peer_left", id: peer }
        console.log(JSON.stringify(event))
      })

      this.gameLobby.on('message', (message) => {
        let payload = JSON.parse(message.data.toString())
        console.log(payload)
      })
    })
})()

I've ruled out browser-specific issues by testing each affected machine with the IPFS benchmark tool which connects me (and every other browser I've tested) to other peers as expected.

ccashwell avatar Mar 01 '18 18:03 ccashwell

I think you need to remove Math.Random() when deploying. When you are doing locally you need Math.Random() for uniqueness on the same client.

And one of my implementation is working on https on firebase.

harrshasri avatar Apr 03 '18 05:04 harrshasri

@harrshasri can you link to that implementation?

eolszewski avatar Jun 13 '18 22:06 eolszewski

@eolszewski Link

harshasoftware avatar Jun 15 '18 19:06 harshasoftware