uniqys / UniqysKit

Uniqys Kit - A toolkit for creating your own DApps
33 stars 2 forks source link

P2P network fails on launching multiple nodes with same port number #15

Open takatoy opened 5 years ago

takatoy commented 5 years ago

Type

bug report

Description

Below error occurs when launching two or more nodes in a same local network, with having the same port numbers in the network config.

p2p:network discover peer QmT22p1UniGbBp8ZtZmemTzo6MykgLi8NkbbriFN8PBFXR +3m
  p2p:network dial protocol uniqys/v1 to QmT22p1UniGbBp8ZtZmemTzo6MykgLi8NkbbriFN8PBFXR +45ms
events.js:167
      throw er; // Unhandled 'error' event
      ^
Error: dialed to the wrong peer, Ids do not match
    at PeerId.createFromPubKey (/Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/libp2p-secio/src/handshake/crypto.js:80:25)
    at pubKey.hash (/Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/peer-id/src/index.js:201:5)
    at Multihashing.Multihashing.digest (/Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/multihashing-async/src/index.js:33:5)
    at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
    at EventEmitter.ChainCore.network.onError.err (/Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/@uniqys/chain-core/dist/index.js:63:24)
    at EventEmitter.emit (events.js:182:13)
    at node.dialProtocol (/Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/@uniqys/p2p-network/dist/network.js:146:32)
    at Dialer._switch.dial [as callback] (/Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/libp2p/src/index.js:314:27)
    at waterfall (/Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/libp2p-switch/src/dial.js:110:12)
    at /Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/async/internal/once.js:12:16
    at next (/Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/async/waterfall.js:21:29)
    at /Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/async/internal/onlyOnce.js:12:16
    at waterfall (/Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/libp2p-switch/src/dial.js:160:7)
    at /Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/async/internal/once.js:12:16
    at next (/Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/async/waterfall.js:21:29)
    at /Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/async/internal/onlyOnce.js:12:16
    at waterfall (/Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/libp2p-switch/src/dial.js:202:16)
    at /Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/async/internal/once.js:12:16
    at next (/Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/async/waterfall.js:21:29)
    at /Users/s-yoshida/projects/uniqys-nuxt-sandbox/node_modules/async/internal/onlyOnce.js:12:16
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Workaround

Set "network" > "libp2pConfig" > "mdns" > "enabled" to false for development usage.

"network": {
  "port": 5665,
  "address": "0.0.0.0",
  "libp2pConfig": {
    "peerDiscovery": {
      "mdns": {
        "interval": 1000,
        "broadcast": true,
        "serviceTag": "uniqys.local",
        "enabled": false
      },
      "bootstrap": {
        "interval": 5000,
        "list": [],
        "enabled": false
      }
    }
  }
}
takatoy commented 5 years ago

Related #7

odanado commented 5 years ago

I ran this official example app in the same local network, with having the same port numbers. As a result, the app didn't fail. https://github.com/libp2p/go-libp2p-examples/tree/master/chat-with-mdns