openevse_esp32_firmware icon indicating copy to clipboard operation
openevse_esp32_firmware copied to clipboard

network not respecting DHCP assigned DNS servers since upgrade to 5.0.0

Open ve6rah opened this issue 2 years ago • 13 comments

I upgraded to 5.0.0 this morning, and ever since that time MQTT and NTP aren't working. All the settings show the same in the front-end as they did before the update, and I have double checked that both MQTT and NTP servers are working properly.

Unsure how to troubleshoot, I don't see much in the way of logs, in developer debug console I see: {"mqtt_connected":0}

Ideas?

ve6rah avatar Sep 20 '23 15:09 ve6rah

After a LOT of digging, and no thanks at all to OpenEVSE's lack of logging/troubleshooting ability, I discovered that it seems to be a DNS issue. I have no idea WHY it's a DNS issue, but when I changed NTP and MQTT servers to IP addresses instead of names, it works.

Still no idea how to troubleshoot the DNS issue though, everything else connected to the same wifi has no problem with the DNS.

ve6rah avatar Sep 20 '23 20:09 ve6rah

That sounds really weird, can't think of anything that has changed in that area.

Yeah the debug in the production builds is not great, we do have a ticket to improve that.

jeremypoulter avatar Sep 20 '23 21:09 jeremypoulter

I tried multiple reboots, I tried a factory reset, no luck. It's obviously having DNS issues, but I don't know where to go from here.

ve6rah avatar Sep 20 '23 21:09 ve6rah

Interesting, I don't believe there's been any change in this area. What servers are you trying to connect to? Are they local servers? Connecting to https://emoncms.org for energy monitoring works fine

glynhudson avatar Sep 25 '23 19:09 glynhudson

DNS servers are local to my network. Or at least that is what the DHCP server is serving, without any form of diagnostics, I can't see if OpenEVSE is trying to access a different DNS service, if that is the case, it would be unsuccessful, as I have firewall off my IoT devices from the public internet. However it would also be poor form for it to ignore the DNS servers supplied through DHCP.

ve6rah avatar Sep 25 '23 19:09 ve6rah

The networking library (mongoose) uses the Google DNS server by default (8.8.8.8), but unfortunately, it doesn't try alternative DNS servers automatically. It should be possible to change the default by inserting

-D MG_DEFAULT_NAMESERVER='"8.8.8.8"' (with the alternative IP address)

into the build_flags section of the platformio.ini (here).

matth-x avatar Sep 26 '23 12:09 matth-x

@ve6rah -

If you have a setting on your router to redirect all DNS requests to local DNS source, that would be a possible workaround for now. I have this set up on my custom LAN router that uses dnsmasq for both DNS and DHCP, so "misbehaving" devices still end up using local DNS whether they want to or not.

Long term fix should be having OpenEVSE respect DNS servers assigned by DHCP, of course.

fhteagle avatar Sep 26 '23 13:09 fhteagle

Right now my short-term fix is to ignore DNS, and put everything in by IP.

However it seems like we've at least figured out why this is happening. Sounds like a badly misbehaving library.

ve6rah avatar Sep 26 '23 13:09 ve6rah

Hum, my wrapper does try to select the router provided IP via MongooseCore::ipConfigChanged() maybe that is not being called...

jeremypoulter avatar Sep 26 '23 15:09 jeremypoulter

Also what DNS names are you trying to resolve?

jeremypoulter avatar Sep 26 '23 15:09 jeremypoulter

The names I'm trying to resolve are both internal to my network. One is the MQTT server, the other is the NTP server. I don't allow IoT devices to connect to the public internet.

ve6rah avatar Sep 26 '23 15:09 ve6rah

That would certainly track, with the DNS server not being set, although can you confirm that you are not using .local? That is mDNS not DNS and not supported.

jeremypoulter avatar Sep 26 '23 15:09 jeremypoulter

The domain names in question are FQDN. They are part of my registered domain, however only served locally.

ve6rah avatar Sep 26 '23 16:09 ve6rah