LibP2P: Connecting Rust and JS

I’ve managed to connect Rust and JS via floodsub (see floodsub branch for code).

Seems like issue was at least twofold:

  1. js-libp2p hangs on secio handshake in crypto.js :: createExchange crypto.js#L48 as of version 0.11.1
  2. No compatible protocols was enabled, fixed by enabling Identify protocol

Seems like js-libp2p-secio is updated to 0.12.1 (but not published to npm yet), maybe this fill fix the freeze. In the meantime, I’ve patched it directly: github.com/folex/libp2p-multilang/blob/floodsub/js/node_modules/libp2p-secio/src/handshake/crypto.js#L57-L69 (sorry it’s not a link, I can’t post more than 2 links).

However, I’m still not sure how to pass PeerID between Rust and JS.

Also peers automatically disconnect after some time, I haven’t figured out the reasons, but I guess it’s because JS doesn’t send any ping-pongs.