Connect libp2p node to a go-ipfs node

I’m running a node app with libp2p. I can create nodes and operate with them.

But I’m unable to connect my libp2p nodes, with nodes running on a cluster with go-ipfs 0.4.18. I get “ERR_ENCRYPTION_FAILED”.

Is is possible to connect a js-libp2p node (1.2.1) to a go-ipfs node (v0.4.18)?

Hello @msalimbene ,

Yes! It is possible. I think the Universal Connectivity project is the best example for you to learn from. It has peers written in js-libp2p, rust-libp2p, and go-libp2p that all connect and form a chat room. There was a demo of this app at IPFSþing 2023

I hope this helps!

Cheers! :beers:
Dave

I’ve asked this same question in a github issue and perhaps the problem is that go-ipfs version I have is quite old:

I do see that in libp2p I’m using Noise as encryption method, but the ipfs configuration of the nodes have no apparent encryption. So, not quite sure, but there could be a problem there.

Having an old version of go-libp2p could be the issues. Also, some cryptography handshakes require that your system clock be set correctly. Check those.

Cheers! :beers:
Dave

1 Like

I’ve tried with a the latest version of kubo-ipfs, but the issue persist. I’ve read in the docs that in kubo-ipfs Noise is enabled by default, but I don’t see it on the nodes config. Could the issue be related to that?

I needed to pass a swarm.key to libp2p configuration options. However, I was able to connect to a kubo-ipfs node with version 0.27, but not to a go-ipfs node with version 0.4.18

to Go-ipfs 0.4.18

libp2p:tcp dialing /ip4/x/tcp/4001/p2p/QmVKuLVFyBX2ZSyB2w7YLpH4AM7YCdaqdNRjwZa9cR335M +0ms
  libp2p:tcp connection opened /ip4/x/tcp/4001/p2p/QmVKuLVFyBX2ZSyB2w7YLpH4AM7YCdaqdNRjwZa9cR335M +162ms
  libp2p:tcp new outbound connection /ip4/x/tcp/4001/p2p/QmVKuLVFyBX2ZSyB2w7YLpH4AM7YCdaqdNRjwZa9cR335M +3ms
CodeError: protocol selection failed
    at DefaultUpgrader._encryptOutbound (file:///Users/salimbene/dev/ipfs/node_modules/libp2p/dist/src/upgrader.js:524:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async DefaultUpgrader.upgradeOutbound (file:///Users/salimbene/dev/ipfs/node_modules/libp2p/dist/src/upgrader.js:199:21)
    at async TCP.dial (file:///Users/salimbene/dev/ipfs/node_modules/@libp2p/tcp/dist/src/index.js:79:22)
    at async DefaultTransportManager.dial (file:///Users/salimbene/dev/ipfs/node_modules/libp2p/dist/src/transport-manager.js:81:20)
    at async queue.add.peerId.peerId [as fn] (file:///Users/salimbene/dev/ipfs/node_modules/libp2p/dist/src/connection-manager/dial-queue.js:154:38)
    at async raceSignal (file:///Users/salimbene/dev/ipfs/node_modules/race-signal/dist/src/index.js:28:16)
    at async Job.run (file:///Users/salimbene/dev/ipfs/node_modules/@libp2p/utils/dist/src/queue/job.js:56:28) {
  code: ‘ERR_ENCRYPTION_FAILED’,
  props: {}
}

to Kubo-ipfs 0.27

2024-03-27 15:39:54 info: dialing up to remotepeer: /ip4/x/tcp/4001/p2p/12D3KooWGnC5m82ccmXayxe5qYtH1PupxuXtZpWEe2swTPfbn4Bk
  libp2p:tcp dialing /ip4/x/tcp/4001/p2p/12D3KooWGnC5m82ccmXayxe5qYtH1PupxuXtZpWEe2swTPfbn4Bk +0ms
  libp2p:tcp connection opened /ip4/x/tcp/4001/p2p/12D3KooWGnC5m82ccmXayxe5qYtH1PupxuXtZpWEe2swTPfbn4Bk +167ms
  libp2p:tcp new outbound connection /ip4/x/tcp/4001/p2p/12D3KooWGnC5m82ccmXayxe5qYtH1PupxuXtZpWEe2swTPfbn4Bk +6ms
  libp2p:tcp outbound connection /ip4/x/tcp/4001/p2p/12D3KooWGnC5m82ccmXayxe5qYtH1PupxuXtZpWEe2swTPfbn4Bk upgraded +699ms
{
  status: ‘open’,
  remoteAddr: Multiaddr(/ip4/x/tcp/4001/p2p/12D3KooWGnC5m82ccmXayxe5qYtH1PupxuXtZpWEe2swTPfbn4Bk),
  remotePeer: PeerId(12D3KooWGnC5m82ccmXayxe5qYtH1PupxuXtZpWEe2swTPfbn4Bk),
  direction: ‘outbound’
}