React Native - could not connect to discovered peer

React Native 0.63.4, testing on an iOS device (12.5.1) (debugger off), no VPN, I get could not connect to discovered peer after I see several peers being discovered. I am using isomorphic-webcrypto and peer-id creation seems fine.
Tested the same connection code in the browser and it works (connected with peers & exchanged messages).

Anyone else managed to get libp2p to work in RN and has some tips?

const libp2p = await Libp2p.create({
    peerId,
    addresses: {
      listen:  [
      '/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star',
      '/dns4/wrtc-star2.sjc.dwebops.pub/tcp/443/wss/p2p-webrtc-star'
    ],
    },
    modules: {
      transport: [
        Websockets,
        WebrtcStar
      ],
      streamMuxer: [Mplex],
      connEncryption: [NOISE],
      peerDiscovery: [Bootstrap],
      dht: KadDHT,
      pubsub: Gossipsub
    },
    config: {
      peerDiscovery: {
        bootstrap: {
          list:  [
'/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb',
        '/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN'
    ]
        }
      },
      dht: {
        enabled: true,
        randomWalk: {
          enabled: true
        }
      }
    }
  })
"dependencies": {
    "libp2p": "^0.30.8",
    "libp2p-bootstrap": "^0.12.2",
    "libp2p-gossipsub": "^0.8.0",
    "libp2p-kad-dht": "^0.20.6",
    "libp2p-mplex": "^0.10.2",
    "libp2p-noise": "^2.0.4",
    "libp2p-webrtc-star": "^0.21.1",
    "libp2p-websockets": "^0.15.2",
    "peer-id": "^0.14.3",
    "protons": "^2.0.0",
    "uint8arrays": "^2.1.2"
  },

@loredanacirstea can you please share how you used libp2p in react native? I get errors due to crypto and a couple of libs that are only available in node

1 Like