Using IPv6 Addresses with UDP packets

Hi everyone!

I am working on a project and I need two ESP32 to communicate over the network sending simple UDP packets.
I have been able to do this using WIFiUDP library, but everything works only if the two microcontrollers are in the same network (I can't do port forwarding for project's reasons).

To solve this issue I thought of using VPN and I found Husarnet that works really well.
I have been able to create the network and add the two ESP32 to it, the problem is that the controllers see each other and get the IPv6 and name of the peer, but WiFiUDP methods to send the packets only work with IPv4 or host name.
Since I don't have the IPv4, I tried to use the host name but it seems it does not work since I get the error "could not get host from dns: 11".

Am I doing something wrong? Any suggestion would be really appreciated.

Thanks in advance,
Francesca

This isn't true. UDP uses the same routing that TCP would use. There may be firewalls in between but that's another story. So why do you think UDP doesn't work if the two boards are not in the same network? Of course the networks must be interconnected in some way and you must ensure not both nodes are behind a NAT device.

If we talk about this project, the two nodes must see each other anyway to establish the VPN, so you don't need it, at least not for the connectivity (security wasn't mentioned as a concern yet).

Anyway, as far as I saw the Husarnet documentation the integration seems to quite seamless, you start the VPN and you can use all underlying ESP32 libraries. Unfortunately the documentation is rather minimal, it doesn't tell anything about how the VPN is integrated into the platform. As the Arduino platform doesn't support IPv6 yet, it may only be possible by using the ESP SDK directly.

I know UDP can be used to communicate between two networks, but in order to do that you need public IPs, and this is not my case (nor my two networks are interconnected).
This is why I thought of using VPN.

What do you mean with saying that the twonodes must see each other anyway? I created a network from the dashboard and then the two ESP32 joined the network.. I can see them online.

The Arduino library WiFiUDP does not support IPv6, but why can't I use the hostname with which the ESP32 joins the VPN?

That's why I mentioned the NAT devices constraint. You didn't define that you're using a private network on two locations, both connected only through NAT devices over the Internet.

The host names just are place holders for the IP addresses. As WiFiUdp does not support IPv6 it doesn't support host names that resolve to IPv6 addresses. You VPN solution does somehow integrate into the web server classes of the ESP32 core, maybe by simply replacing the corresponding library. As the VPN code seems to be available only for the PlatformIO platform but not for the Arduino IDE, this forum might be the wrong place to ask for further help.
The documentation doesn't say anything about how the integration works and I can install the source code only if I'd install PlatformIO. A PlatformIO support forum is probably better fitted to help you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.