Page 1 of 1

Specify NetIf interface for specific services

Posted: Mon Sep 16, 2024 6:26 pm
by maurizio.scian
Hi,

I have a scenario where I use AP, WiFi STA and ethernet STA.
I have several network services:
- Webserver, active on all interfaces
- MQTT, which I would like to activate exclusively on an STA interface
- PING session active on the gateway of the ethernet interface (the switch is in my card, so the linkup is always active, I need to ping the gateway to cause the disconnection event)
- PING session on 8.8.8.8 to identify if the ethernet network reaches the internet
- UDP socket for remote log, which I would like to activate exclusively on an STA interface
- mDNS (this is not implemented yet) to check for the presence of some devices with which I will have to communicate in the future, only on ethernet

Currently, if everything is connected, everything works. Unfortunately, if the STA connection remains active (both ethernet and WiFi) despite not being connected to the WAN, MQTT and UDP sockets do not resolve the address in DNS and it is not possible to force a different interface for the connection. In my case it is not enough to change the route_prio of the netif interfaces, and even less the default netif interface (https://docs.espressif.com/projects/esp ... netif.html).

I read this topic (viewtopic.php?t=15157) regarding the choice of the interface to use in MQTT but I can't apply the hooks. This little guide (https://github.com/espressif/esp-idf/issues/3581) does not seem to work with version 5.2.

Has anyone had the need to manage network services more precisely?