Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
'No route to host' error in beta 340009 when using multicast
-
Hi,
I have a script to discover devices on the local network which seems to no longer work.
The error is:
ssdp_socket.sendto('\r\n'.join(msg).encode('ascii'), (dst, 1900))
OSError: [Errno 65] No route to hostI know this worked before but not sure when.
I just started using Pythonista again with the new beta.
Could it be that the beta does not have the Multicast Networking capability?
https://developer.apple.com/forums/thread/715204Minimal example:
import socket import sys dst = "239.255.255.250" port = 1900 msg = [ 'M-SEARCH * HTTP/1.1', f'Host:{dst}:{port}' , 'ST:upnp:rootdevice', 'Man:"ssdp:discover"', 'MX:1', ''] ssdp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) ssdp_socket.settimeout(10) ssdp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) ssdp_socket.sendto('\r\n'.join(msg).encode('ascii'), (dst, port)) while True: try: data, addr = ssdp_socket.recvfrom(32*1024) except socket.timeout as e: print(f"{e = }") break print("[+] %s\n%s" % (addr, data.decode('ascii')))
(Edited based on @ccc suggestion)
Thanks
-
@ttobias said in 'No route to host' error in beta 340009 when using multicast:
except socket.timeout: break
Change that to this...
except socket.timeout as e: print(f"{e = }") break
-
@ccc Makes sense, I changed it in the code if someone wants to use the code.
But the error is happening in the line above the while loop.The
.sendto(...)
is already failing with the 'No route to host' error.
The script works fine if executed on a desktop, so I assume it might be related to the missing capability. -
@ttobias It looks like multicast networking requires an additional entitlement from Apple that I have to apply for, and explain why my app needs this... I think the previous version might still have worked because it was built with an older iOS SDK. I'll look into this, but it might take a little while.
-
@omz Thanks, sure no problem.
It's definitely a special use case.
If you can't convince Apple that's no major problem for me all around I'm very happy with the latest update.