How to connect the ESP32 board to a broker using paho_mqtt module

I successfully connected my ESP32 board with a wifi network via the paho-mqtt example code base.
However, I don’t really know how to proceed with the work from now on. Like how to connect the board with either a local broker that runs on my Linux machine or a public broker like
When I try to check the network by typing ifocnfig inside the riot terminal, all I can get is just a local link ipv6 address like this:

2022-08-12 22:58:00,054 # ifconfig
2022-08-12 22:58:00,059 # Iface ET0 HWaddr: 3c:61:05:13:46:54 Link: up State: up
2022-08-12 22:58:00,061 #         Link type: wireless
2022-08-12 22:58:00,069 #         inet6 addr: fe80:0:0:0:3e61:5ff:fe13:4654 scope: link state: valid 

I have tried paho-mqtt on native board, and it worked. So basically I don’t know how to connect my board to the outer work…
Big thanks to anyone who knows the answer to my question!

Every interface comes up with an IPv6 Link-Local (fe80:) address, so that doesn’t mean that you have any connectivity at all. It is likely that you are not connected to your wifi network at all with your build. I haven’t tried the paho-mqtt build, but I will and see what help I can offer. (I need to do some ESP32 work this week anyway)

Usually, you should receive the GUA prefix from your router after some time, once a router advertisement has been received. With that GUA you should then be able to connect any address outside.

Unless you do not have IPv6 in your network. You could try building with

LWIP_IPV4=1 LWIP_IPV6=0 BOARD="<your board>" make -C examples/paho-mqtt -j flash

in that case.

Hi, thank you for your answer! The ipv4 setting does work!
The only problem is that the connection between the ESP32 node and broker is so unstable, such that I have to re-connect to the broker once after a few pub/sub. I wonder if that’s a problem related to the board itself, cause the node built on the native board works perfectly. Thank you!

Is the WiFi connection still alive when you have to reconnect or do you have to reset the board?

The wifi connection is still on, only the MQTT connection itself is unstable. I have to re-connnect to the broker for every 30s. Screenshot from 2022-08-16 17-06-46