Libp2p JS commmunication between nodes on internet

I cloned libp2p js module and used the chat example. It worked fine on the same system and then I tried using it on LAN. On LAN also it worked fine. Then I tried to make it work on Internet between 2 systems connected to different ISPs using phone internet tethering. This time however the systems couldn’t communicate and find each other. Please tell me a way to fix this issue and make it work.

Have you setuped (or using a public one) STUN server ?

A stun server will have as goal to punch a hole in the nat and your bug looks exacly how WebRTC looks before nat punching was a thing.

Is there a decentralized alternative to the STUN based solution?

Running a Relay is another option to get TURN behavior. There are other relays in the wild and any node can be configured to behave as a TURN relay.

There is discussion of allowing nodes to act as webrtc signaling servers to better support decentralization of signaling, https://github.com/libp2p/specs/pull/159