Examples failing... help! New to libp2p

I am new to libp2p and running into two problems with two different sets of example code found on the libp2p website. I am running Windows 10 virtual machine and using the libp2p-js lib.

First Example:

I am receiving the following error after setting up the getting started ping/pong example code at: https://docs.libp2p.io/tutorials/getting-started/javascript/

Error: UnhandledPromiseRejectionWarning: Error: The dial request has no addresses

  • node index.js /ip4/127.0.0.1/tcp/63963/p2p/QmYdWmXac5AxnQoJ5cwRAjicbx …
  •   + CategoryInfo          : NotSpecified: ((node:15584) Un...as no addresses:String) [], RemoteException
      + FullyQualifiedErrorId : NativeCommandError
    
      at Dialer.connectToPeer (C:\Users\...\node_modules\libp2p\src\dialer\index.js:74:21)
    
    

I have ensured the example code is copied as expected. Launching the first node (the listener) works fine, however launching a second node (the dialer) with args fails. I have tried sending the address in various address formats, as well as sending the multicast object, directly to 'node.ping(..)'. All fail.

Looking at the libp2p src, it looks the src/dialer/index.js dialer connectToPeer() method is getting caught on (!dialTarget.addrs.length). It maybe looks like libp2p’s ping/index.js ping(node, peer) method is not taking the multiaddr format that is being passed in.

Is there a chance this format has changed or is not fully implemented properly in the js lib? Noticing there is only one param being sent in the example code for ping, but two params are expected in the ping src file.

Second Example:

I have setup the chat example from https://github.com/libp2p/js-libp2p/tree/master/examples/chat:

Similarly to the first example, I am able to successfully deploy the first node (listener) but the second node (dialer) fails due the connection not being multiplexed (error below). I am using the code exactly as specified in the example, and have confirmed the multiplexing module is enabled.

Error: node : (node:14652) UnhandledPromiseRejectionWarning: Error: connection is not     + CategoryInfo          : NotSpecified: ((node:14652) Un...not multiplexed:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
    at ClassIsWrapper.errConnectionNotMultiplexed [as _newStream] (C:\Users\...\node_modules\libp2p\src\upgrader.js:278:21)

New to libp2p and would really love any support here. Thanks!

Hello @n30

Can you let me know the libp2p version you are running?
I tried both issues on macOS and they are both working for me.

It might be worth if you try to replicate it here: https://github.com/libp2p/js-libp2p/blob/master/test/core/ping.node.js#L28
I tried to add:

it('ping once from peer0 to peer1 using a multiaddr', async () => {
    const ma = `${nodes[1].multiaddrs[0]}/p2p/${nodes[1].peerId.toB58String()}`
    const latency = await nodes[0].ping(ma)

    expect(latency).to.be.a('Number')
  })

and it also worked for me. All this using the latest in master

Actually, I could replicate the example from the docs website.
Looking into it now

Thanks for flagging this!

https://github.com/libp2p/js-libp2p/pull/719 should fix the issue

Nice! Thanks for the quick fix. I update the lib based on your PR and that seemed to fix the ping issue. FYI: I tried to pull down the latest NPM package but the change wasn’t in there. I think the build may have failed according to TravisCI. Not sure how the NPM pkgs get packaged up.

Did you have any thoughts on the second example I mentioned due to multiplexing? Not sure what to do there… wondering if it could be a network or Windows thing. Thanks for your help.

Yeah, it still needs to be released.

I could not replicate that one in macOS. The example is doing good for me. Can you open an issue in the repo? I think that it would be the easier way to track a potential issue there