Closed ondrej1024 closed 1 year ago
Hello,
I am pretty sure this has to do with MicroPython having a default MDNS implementation on the RPi Pico already activated and you need to disable it before being able to use MDNS for service discovery.
However, the implementation has currently only been tested with ESP32 configuration and it has recently pointed out to me that it will likely not work on other implementations: https://github.com/cbrand/micropython-mdns/issues/8#issuecomment-1443703889
If you only want to see / have an address in WiFi for you device and not any kind of service discovery you might not want and/or need to use this library: https://github.com/cbrand/micropython-mdns#intended-audience
The hostname if you do a MDNS lookup should already advertise itself on the network: https://github.com/micropython/micropython/commit/2ccf030fd1ee7ddf7c015217c7fbc9996c735fd1 (This is for esp32 but I think the rpi pico also has something similar when this error message comes up).
I really cannot find any documentation or source code about this MDNS service built into the Pico Micropython build. And avahi-discover
doesn't find the Pico advertising itself in the network.
So my guess is it actually isn't there and your MDNS package doesn't run on the Pico either (for the reasons you mentioned), so the EADDRINUSE it causes might just be misleading.
avahi-discover
as far as I am aware of is searching for services not for hosts itself: https://linux.die.net/man/1/avahi-browse
What I presume is going on that it registers its host name (A Record) and that is not seen by avahi-discover (which is scanning for SRV
records). You can see if the host name on MDNS is available if you know it by just doing ping {host_name}.local
or also skip the local. This should be resolvable. The EADDRINUSE
clealry states that there is something in the code base listening on PORT 5353 which is 95% surely an MDNS service which is embedded in the deployment of Pico.
You can see if the host name on MDNS is available if you know it by just doing
ping {host_name}.local
or also skip the local.
Yes, I tried that, but without success. I tried the hostname which I get from network.hostname()
on the Pico.
The
EADDRINUSE
clealry states that there is something in the code base listening on PORT 5353
I also did a port scan of the Pico but this didn't find any open ports :roll_eyes:
Alright sorry about that then. I think without having a Pico here myself I can not help you any further.
Hope you'll find the issue and figure it out! Closing this for now. Feel free to open a new issue once you've debugged the base issues on the Pico. I would like to add support for the library for other systems, too so would be eager to hear if you get it to run and if not what error message you receive.
Good luck :)
I was able to get around that error by compiling micropython myself, and setting the include for LWIP_MDNS_RESPONDER
to 0.
I got past the EADDRINUSE issue at least. Still trying to successfully resolve a service name.
If anyone is interested, here is the explanation why the MDNS port on the Pico is used by default but it is actually not advertising anything: https://github.com/micropython/micropython/issues/8946
@captncraig i just started my own project (my first), on the raspberry pi pico wh, i am facing the same issue. But i lack the knowlegde how i can overwrite this, like you said. Can you help me out how to get this working?
@captncraig i just started my own project (my first), on the raspberry pi pico wh, i am facing the same issue. But i lack the knowlegde how i can overwrite this, like you said. Can you help me out how to get this working?
cd micropython
nano ./ports/rp2/lwip_inc/lwipopts.h
and replace the 1
in line 35 after #define LWIP_MDNS_RESPONDER
to a 0
, then press ctrl
+ x
to save and hit enter
to confirm saving.cd mpy-cross && make
cd ../ports/rp2 && make BOARD=RPI_PICO_W submodules && make BOARD=RPI_PICO_W
With the tip from @captncraig i can successfully get a txtService. Thank man :)
also why is this issue closed ? @cbrand This is not fixed at all. Would be way easier to find, if its an open issue!
@arag0re Hey :) Sorry but this is a bit out of scope of the library.
As this is a build issue for one specific device it makes more sense to me to track it outside of the actual library, as the library in itself is functional.
So keeping the issue open makes the management of this very hard, as I do not have any affiliation with the actual MicroPython project which seems to be the main issue facing here.
There is a caveats section in the README outlining that this is something which might be required for the individual ports for differnt boards to be done (Disabling MDNS functionality): https://github.com/cbrand/micropython-mdns?tab=readme-ov-file#caveats
I think with the information you all provided though I can also release a new version which does not only provide builds for the ESP32 but also for the RPi Pico in the next release and link this issue to make it easier findable in the future so that hopefully more people can benefit from the research done in this ticket.
Hi guys, after implementing @arag0re fix and installing mDNS from @cbrand I was able to use cbrands example for mDNS responder and was able to ping my pico at hostname.local
Can anyone provide any direction on how to integrate this into a web server? I'm fairly new to this and there is little documentation on how to implement this mDNS package into a webserver using micropython. I'm just wanting to be able to access my pico's web page using hostname.local
I added into the release pipeline for 1.5.0 an RPi Pico build: https://github.com/cbrand/micropython-mdns/releases/tag/1.5.0
In the future all releases and new MicroPython versions will also be released for RPi Pico.
I am trying to run the service_responder.py example program on a RPi Pico with Ethernet port and get this error:
OSError: [Errno 98] EADDRINUSE
Does this mean the mDNS service is already active in the MP firmware? If so, should I see the Pico advertising its host name in the local network? I tried with an mDNS browser but could not find the Pico.
MP version is this:
MicroPython v1.19.1-910-g4937174b4 on 2023-03-01; W5500-EVB-Pico with RP2040
Thanks.