libp2p / docs

Documentation site for the libp2p project.
https://docs.libp2p.io/
Other
59 stars 88 forks source link

js-libp2p ping-pong - TypeError: node.ping is not a function #324

Closed stefan1010 closed 1 year ago

stefan1010 commented 1 year ago

Receiving: TypeError: node.ping is not a function

Running on: "dependencies": { "@chainsafe/libp2p-noise": "^12.0.0", "@libp2p/mplex": "^8.0.3", "@libp2p/tcp": "^7.0.1", "libp2p": "^0.45.1", "multiaddr": "^10.0.1" }

Maybe implementation has changed?

maschad commented 1 year ago

Correct we recently integrated the use of optional services, and so the ping method is on the PingService.

Thanks for catching this! We do need to update the getting started docs. Would you be able to open a PR?

stefan1010 commented 1 year ago

Would love to, but from the docs I can't figure out how to use the PingService.

From configuring it as a service on the node, I would expect it to be callable from node.services.ping. But that gives me ..not a function as well.

Not configuring it and directly calling pingService(ma) is the only working solution I found, but it's not a method on the pingService as you mentioned, so this is confusing me. I also don't see a way to get the latency, as it is part of the getting started docs.

maschad commented 1 year ago

I would need to see your configuration but here's an example of how it's called on the ping service i.e. essentially node.services.ping.ping(ma) . I hope that clears things up.

stefan1010 commented 1 year ago

Receiving 403 permission denied when I try to push my branch.

Sorry, I dont know how to create the PR. Would be my first one on github.

maschad commented 1 year ago

Sure no worries, you may want to read through the Github docs on creating a pull request. Once you've done that then I would suggest taking a look at our section on contributing content

stefan1010 commented 1 year ago

Opened this PR: https://github.com/libp2p/docs/pull/325

Not sure how to link it to this issue. Not sure if the PR follows any given conventions. Any hints and advice appreciated.

maschad commented 1 year ago

Thanks for this PR. You can get more info on how to link docs here I left some comments on the PR.