nickovs / slimDNS

Simple, Lightweight Implementation of Multicast DNS
Apache License 2.0
86 stars 9 forks source link

EADDRINUSE Error #9

Closed JJGO closed 1 year ago

JJGO commented 1 year ago

I'm using the first snippet in the docs on a ESP32 board and it immediately fails with the following error:

Traceback (most recent call last):
  File "main.py", line 5, in <module>
  File "slimDNS.py", line 203, in __init__
OSError: [Errno 112] EADDRINUSE
MicroPython v1.19.1 on 2022-06-18; ESP32 module with ESP32

I managed to run the same code on a ESP8266 successfully, so not sure what is going on here.

I can confirm that I am NOT initializing the web repl and the boot code is just connecting to my Wi-Fi network.

nickovs commented 1 year ago

I think that the problem is that you don't need slimDNS on the ESP32 Micropython any more, since it is built in these days, and the built-in version is has already bound to the relevant address and port.

To use the built-in support on the ESP32 it should be sufficient to set the host name using something like wlan.config(dhcp_hostname="device_name") before you call wlan.connect() and then your device will be discoverable and calls to socket.getaddrinfo() will work for .local domain names.

JJGO commented 1 year ago

Yes, I forgot to follow up on this but you are completely right, the EADDRINSUE is linked to the native ESP32 mDNS support. Using the dhcp_hostname param in config was enough to configure it and slimDNS is then not needed in the ESP32.

Maybe it's worth adding a disclaimer/note in the README to prevent future issues about this being reported.