Open djav35 opened 1 year ago
Thanks for creating this ticket, there's been an issue created to add interoperability tests for mDNS to ensure this works across implementations: https://github.com/libp2p/test-plans/issues/179
It might be worth recording a packet trace using Wireshark, and inspect the mDNS messages exchanged and check if they comply with the mDNS spec. zeroconf is the mDNS implementation we're using, it might also be helpful to add some debug statements there. @djav35, want to take a stab at debugging this?
It might be worth recording a packet trace using Wireshark, and inspect the mDNS messages exchanged and check if they comply with the mDNS spec. zeroconf is the mDNS implementation we're using, it might also be helpful to add some debug statements there. @djav35, want to take a stab at debugging this?
Thanks. I just edited the issue providing packet captures.
To close this issue we should document what causes the incompatibility and suggestions for fixes (either in go-libp2p and other libp2p implementations).
For testing cross implementation interop, let's use this issue: https://github.com/libp2p/test-plans/issues/179.
I found in the test that js-libp2p can discover the nodes of go-libp2p, but go-libp2p cannot discover the nodes of js-libp2p.
I tracked the problem and found that it was mainly caused by this piece of logic: https://github.com/libp2p/zeroconf/blob/9ff955d44bca57ab14942285552c0b34e9abbad8/client.go#L285
Since serviceTypeName and serviceName must be different, go back and determine whether there is an A or AAAA record in the mdns response answer.
There is no A record in the response of js-libp2p, so the package will be discarded:
There is an A record in go-libp2p, so it can be processed correctly.
There are many ways to solve this problem:
If possible please let me provide pr❤.
mDNS discovery protocol does not work between implementations of Go and Javascript.
I'm trying to set up basic chat example where nodes discover each other through mDNS, looking at the examples provided in go-libp2p and js-libp2p (which leverage the mdns libraries "github.com/libp2p/go-libp2p/p2p/discovery/mdns" and @libp2p/mdns). The network packets sent by both implementations are, apparently, in the same format.
Both Go <-> Go and Js <-> Js work. I've also tried Rust examples and no cross-implementation discovery seems to work.
Connecting to the other node directly (bootstrap mode) works fine after making sure Js is using the yamux multiplexer.
Edit: I add captures of packets sent from Go and Js. Go:
Js:
Although there are some small differences in the format, from what I understand Go implementation only looks at the TXT record, and expects to find all information there (full multiaddress prefixed with "dnsaddr="), which is exactly what Js implementation is providing. But please correct me if I'm wrong.
Version Information