Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeError: The dial request has no valid addresses #1673

Closed
fastalks opened this issue Apr 4, 2023 · 0 comments · Fixed by libp2p/js-libp2p-mdns#192
Closed

CodeError: The dial request has no valid addresses #1673

fastalks opened this issue Apr 4, 2023 · 0 comments · Fixed by libp2p/js-libp2p-mdns#192
Labels
kind/bug A bug in existing code (including security flaws)

Comments

@fastalks
Copy link

fastalks commented Apr 4, 2023

  • Version: libp2p:"^0.43.3"
  • Platform: MacOS 12.5.1
  • Subsystem: connection-manager

Severity: High

Description:

2.js

import { createLibp2p } from 'libp2p'
import { tcp } from '@libp2p/tcp'
import { mplex } from '@libp2p/mplex'
import { noise } from '@chainsafe/libp2p-noise'
import { mdns } from '@libp2p/mdns'

const createNode = async () => {
  const node = await createLibp2p({
    addresses: {
      listen: ['/ip4/0.0.0.0/tcp/0']
    },
    transports: [
      tcp()
    ],
    streamMuxers: [
      mplex()
    ],
    connectionEncryption: [
      noise()
    ],
    peerDiscovery: [
      mdns()
    ]
  })

  return node
}

;(async () => {
  const [node1, node2] = await Promise.all([
    createNode(),
    createNode()
  ])

  node1.addEventListener('peer:discovery', (evt) => {
    console.log('Discovered1:', evt.detail.id.toString())
    evt.detail.multiaddrs.forEach((ma) => {
      console.log('Discovered1:',ma.toString())
    })
    node1.dial(evt.detail.id).catch(err => {
      console.log(`Could not dial ${evt.detail.id}`, err)
    })
  })

  node2.addEventListener('peer:discovery', (evt) => {
    console.log('Discovered2:', evt.detail.id.toString())
    evt.detail.multiaddrs.forEach((ma) => {
      console.log('Discovered2:',ma.toString())
    })
  })

  node1.connectionManager.addEventListener('peer:connect', (evt) => {
    console.log('connect to: ', evt.detail.remotePeer.toString())
  })
  node1.connectionManager.addEventListener('peer:disconnect', (evt) => {
    console.log('disconnect to: ', evt.detail.remotePeer.toString())
  })

})();

I got these error

Discovered1: 12D3KooWEULe9GKMCbMLksKhBwktcpELDuW3tTSxsax19X9MN1Qg
Discovered1: /ip4/127.0.0.1/tcp/54757/p2p/12D3KooWEULe9GKMCbMLksKhBwktcpELDuW3tTSxsax19X9MN1Qg/p2p/12D3KooWEULe9GKMCbMLksKhBwktcpELDuW3tTSxsax19X9MN1Qg
Discovered1: /ip4/192.168.1.176/tcp/54757/p2p/12D3KooWEULe9GKMCbMLksKhBwktcpELDuW3tTSxsax19X9MN1Qg/p2p/12D3KooWEULe9GKMCbMLksKhBwktcpELDuW3tTSxsax19X9MN1Qg
Could not dial 12D3KooWEULe9GKMCbMLksKhBwktcpELDuW3tTSxsax19X9MN1Qg CodeError: The dial request has no valid addresses
    at DefaultDialer.dial (file:///Users/xxxxx/Desktop/project/AwesomeProject/nodejs-assets/nodejs-project/node_modules/libp2p/dist/src/connection-manager/dialer/index.js:102:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async DefaultConnectionManager.openConnection (file:///Users/xxxxx/Desktop/project/AwesomeProject/nodejs-assets/nodejs-project/node_modules/libp2p/dist/src/connection-manager/index.js:309:32)
    at async Libp2pNode.dial (file:///Users/xxxxx/Desktop/project/AwesomeProject/nodejs-assets/nodejs-project/node_modules/libp2p/dist/src/libp2p.js:260:16) {
  code: 'ERR_NO_VALID_ADDRESSES',
  props: {}
}
Discovered2: 12D3KooWKEXQCegcksF23DCQaVCBNuNUqqk1x2eSJCs9Hwgu3xhR
Discovered2: /ip4/127.0.0.1/tcp/54758/p2p/12D3KooWKEXQCegcksF23DCQaVCBNuNUqqk1x2eSJCs9Hwgu3xhR/p2p/12D3KooWKEXQCegcksF23DCQaVCBNuNUqqk1x2eSJCs9Hwgu3xhR
Discovered2: /ip4/192.168.1.176/tcp/54758/p2p/12D3KooWKEXQCegcksF23DCQaVCBNuNUqqk1x2eSJCs9Hwgu3xhR/p2p/12D3KooWKEXQCegcksF23DCQaVCBNuNUqqk1x2eSJCs9Hwgu3xhR

Steps to reproduce the error:

@fastalks fastalks added the need/triage Needs initial labeling and prioritization label Apr 4, 2023
achingbrain added a commit to libp2p/js-libp2p-mdns that referenced this issue Apr 7, 2023
The libp2p address manager does this so we can just treat the
addresses as opaque here.

Fixes libp2p/js-libp2p#1673
@achingbrain achingbrain added kind/bug A bug in existing code (including security flaws) and removed need/triage Needs initial labeling and prioritization labels Apr 7, 2023
achingbrain added a commit to libp2p/js-libp2p-mdns that referenced this issue Apr 7, 2023
The libp2p address manager does this so we can just treat the
addresses as opaque values here.

Fixes libp2p/js-libp2p#1673
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants