Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raspberrypi Out of MDNS service slots #9127

Open
anecdata opened this issue Apr 1, 2024 · 0 comments
Open

raspberrypi Out of MDNS service slots #9127

anecdata opened this issue Apr 1, 2024 · 0 comments
Labels
bug network rp2 Raspberry Pi RP2 Micros
Milestone

Comments

@anecdata
Copy link
Member

anecdata commented Apr 1, 2024

CircuitPython version

Adafruit CircuitPython 9.1.0-beta.0 on 2024-03-28; Adafruit QT Py ESP32-S3 4MB Flash 2MB PSRAM with ESP32S3

vs.

Adafruit CircuitPython 9.1.0-beta.0 on 2024-03-28; Raspberry Pi Pico W with rp2040

Code/REPL

import time
import os
import traceback
import microcontroller
import wifi
import socketpool
import mdns

PORT1 = 8086
PORT2 = 8088

time.sleep(3)  # wait for serial
print(f'{os.uname()=}')
print(f'{microcontroller.cpu.reset_reason=}')  # is device just coming off a reset?
print(f'{os.getenv("CIRCUITPY_WEB_API_PASSWORD")=}')  # check for web workflow

mdns_server = mdns.Server(wifi.radio)
mdns_server.hostname = "slots-code-py"
try:
    print(f"http://{mdns_server.hostname}.local.:{PORT1} starting...")
    mdns_server.advertise_service(service_type="_fake", protocol="_udp", port=PORT1)
    print(f"http://{mdns_server.hostname}.local.:{PORT2} starting...")
    mdns_server.advertise_service(service_type="_blah", protocol="_tcp", port=PORT2)
except RuntimeError as ex:
    traceback.print_exception(ex, ex, ex.__traceback__)
print("Done.")

Behavior

Fresh reset in each case. Web workflow is not enabled.

espressif allows (as expected) multiple unique service-protocol-port combinations. raspberrypi does not.

The only limitation noted in the docs is:

service_type and protocol can only occur on one port. Any call after the first will update the entry’s port.

https://docs.circuitpython.org/en/latest/shared-bindings/mdns/index.html#mdns.Server.advertise_service

espressif output (successful):

os.uname()=(sysname='ESP32S3', nodename='ESP32S3', release='9.1.0', version='9.1.0-beta.0 on 2024-03-28', machine='Adafruit QT Py ESP32-S3 4MB Flash 2MB PSRAM with ESP32S3')
microcontroller.cpu.reset_reason=microcontroller.ResetReason.SOFTWARE
os.getenv("CIRCUITPY_WEB_API_PASSWORD")=None
http://slots-code-py.local.:8086 starting...
http://slots-code-py.local.:8088 starting...
Done.

raspberrypi output (unsuccessful):

os.uname()=(sysname='rp2040', nodename='rp2040', release='9.1.0', version='9.1.0-beta.0 on 2024-03-28', machine='Raspberry Pi Pico W with rp2040')
microcontroller.cpu.reset_reason=microcontroller.ResetReason.SOFTWARE
os.getenv("CIRCUITPY_WEB_API_PASSWORD")=None
http://slots-code-py.local.:8086 starting...
http://slots-code-py.local.:8088 starting...
Traceback (most recent call last):
  File "code.py", line 32, in <module>
RuntimeError: Out of MDNS service slots
Done.

If web workflow is enabled, results are similar...

espressif output (successful):

os.uname()=(sysname='ESP32S3', nodename='ESP32S3', release='9.1.0', version='9.1.0-beta.0 on 2024-03-28', machine='Adafruit QT Py ESP32-S3 4MB Flash 2MB PSRAM with ESP32S3')
microcontroller.cpu.reset_reason=microcontroller.ResetReason.SOFTWARE
os.getenv("CIRCUITPY_WEB_API_PASSWORD")=passw0rd
http://slots-code-py.local.:8086 starting...
http://slots-code-pylocal.:8088 starting...
Done.

raspberrypi output (unsuccessful - fails on the first .advertise_service):

os.uname()=(sysname='rp2040', nodename='rp2040', release='9.1.0', version='9.1.0-beta.0 on 2024-03-28', machine='Raspberry Pi Pico W with rp2040')
microcontroller.cpu.reset_reason=microcontroller.ResetReason.SOFTWARE
os.getenv("CIRCUITPY_WEB_API_PASSWORD")=passw0rd
http://slots-code-py.local.:8086 starting...
Traceback (most recent call last):
  File "code.py", line 20, in <module>
RuntimeError: Out of MDNS service slots
Done.
@anecdata anecdata added bug network rp2 Raspberry Pi RP2 Micros labels Apr 1, 2024
@tannewt tannewt added this to the Long term milestone Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug network rp2 Raspberry Pi RP2 Micros
Projects
None yet
Development

No branches or pull requests

2 participants