I saw rust-libp2p has a holepunching example but go-libp2p does not. So I wanted to create one, but I am having an issue with my code:
A node run by this is able to get holepunched, but running this code on a second node in a different network will fail to holepunch due to “failed to open hole-punching stream: failed to negotiate protocol: protocols not supported: [/libp2p/dcutr]”.
But when I use tools like Max’s libp2p lookup (GitHub - mxinden/libp2p-lookup: Lookup a peer by its id or address.) it will show that my node does support this protocol and due to the ‘export GOLOG_LOG_LEVEL=p2p-holepunch=debug’ I know for a fact that other nodes are also able to holepunch me (and I also can do it manually using vole [github com/ipfs-shipyard/vole] but I am unable to holepunch with my own code… Can someone please explain what is wrong with the code I linked at the start of this message?
Thanks and have a nice day!
Edit: I also would be interested to know if gossipsub is compatible with relayed connections (in case some is unable to holepunch through the home network) or if topic messages do not get distributed by ipfs teams bootstrap servers which means a direct connection upgrade would be necessary?
Not many people seem to reply to threads opened here but I will try it anyways. I added another example so the code i sent that shows how gossipsub only works if both nodes are in the same LAN but it silently fails when they are not in the same network but have discovered each other via relay servers and were supposed to holepunch to a direct connection. Can someone please test if it works with their setup? Run two nodes that are not in the same network using this code and see if they can receive the topic messages from each other:
Today I tried it with a different network and I get the same issue, so it is likely not related to my setup. Anyone have an idea why holepunching fails? I also added a direct chat example which works fine locally but when using two peers in different networks it keeps failing to send messagses due to “failed to open stream: context deadline exceeded”…
I’m interested in hole punching too, in particular with go-libp2p-kad-dht. Frankly I haven’t tested at all yet, so maybe it just works now. Did you get anywhere with your solution, felix?
Sadly, I haven’t found a fix yet and I am not in a position to be able to try lots of different networks. Please let me know when you find a working example!