File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed
tests/perceptor-host-test/python Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change 55import sys
66import time
77from aiohttp import web , WSMsgType
8- from zeroconf import Zeroconf , ServiceInfo
8+ from zeroconf import Zeroconf , ServiceInfo , IPVersion
99import netifaces
1010import socket
1111
@@ -309,22 +309,19 @@ async def root_handler(request):
309309 else :
310310 print ("SSL keys not found, using HTTP" )
311311
312+ # Need real IP
313+ local_ip = socket .gethostbyname (socket .gethostname ()).split ('%' )[0 ]
314+
312315 # Start Zeroconf
313- zeroconf = Zeroconf ()
316+ zeroconf = Zeroconf (ip_version = IPVersion . V4Only )
314317 try :
315- # Need real IP
316- s = socket .socket (socket .AF_INET , socket .SOCK_DGRAM )
317- s .connect (("8.8.8.8" , 80 ))
318- local_ip = s .getsockname ()[0 ]
319- s .close ()
320-
321318 info = ServiceInfo (
322319 "_allspark._tcp.local." ,
323320 f"{ config ['serviceName' ]} ._allspark._tcp.local." ,
324321 addresses = [socket .inet_aton (local_ip )],
325322 port = config ['port' ],
326- properties = {'path' : '/' },
327- server = f"{ socket . gethostname () } .local."
323+ properties = {},
324+ server = f"{ local_ip } .local."
328325 )
329326 zeroconf .register_service (info )
330327 print (f"Advertising Bonjour service: { config ['serviceName' ]} on { local_ip } :{ config ['port' ]} " )
You can’t perform that action at this time.
0 commit comments