forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
raspberrypi Out of MDNS service slots #9127
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
Comments
Re-tested with CircuitPython 9.2.5. Issue not resolved. |
|
This was referenced Mar 22, 2025
I just wanted to check if there was any memory impact, and it's <1KB for 25 slots. Haven't (yet) tried running services on all of those slots. Thanks, eightycc! code.py.# Adafruit CircuitPython 9.2.6 on 2025-03-23; Pimoroni Pico Plus 2 W with rp2350b
import time
import os
import gc
import random
import traceback
import microcontroller
import wifi
import mdns
BASE_PORT = 8000
NUM_SLOTS = 26 # up to 25 supported, RuntimeError: Out of MDNS service slots on the 26th
def random_service():
svc = bytearray(b'_')
for _ in range(0, 8):
svc.append(random.choice(b'abcdefghijknlmnopqrstuvwxyz'))
return svc.decode()
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
gc.collect()
print(f'{gc.mem_free()=}')
mdns_server = mdns.Server(wifi.radio)
try:
for slot in range(NUM_SLOTS):
service_type = random_service()
protocol = '_udp'
port = BASE_PORT + slot
print(f"Starting {service_type}.{protocol} on {mdns_server.hostname}.local.:{port}")
mdns_server.advertise_service(service_type=service_type, protocol=protocol, port=port)
gc.collect()
print(f'{gc.mem_free()=}')
except RuntimeError as ex:
traceback.print_exception(ex, ex, ex.__traceback__)
print("Done.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CircuitPython version
Code/REPL
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:
https://docs.circuitpython.org/en/latest/shared-bindings/mdns/index.html#mdns.Server.advertise_service
espressif
output (successful):raspberrypi
output (unsuccessful):If web workflow is enabled, results are similar...
espressif
output (successful):raspberrypi
output (unsuccessful - fails on the first.advertise_service
):The text was updated successfully, but these errors were encountered: