runtime/ServicePublisher.py
changeset 4037 4127c64df073
parent 3750 f62625418bff
child 4040 ea2db66b185f
--- a/runtime/ServicePublisher.py	Wed Oct 16 12:18:14 2024 +0200
+++ b/runtime/ServicePublisher.py	Wed Nov 13 23:10:36 2024 +0100
@@ -34,7 +34,6 @@
 
 class ServicePublisher(object):
     def __init__(self, protocol):
-        # type: fully qualified service type name
         self.serviceproperties = {
             'description': 'Beremiz remote PLC',
             'protocol': protocol
@@ -50,12 +49,12 @@
     def RegisterService(self, name, ip, port):
         try:
             self._RegisterService(name, ip, port)
-        except Exception:
+        except Exception as e:
+            print(f"Failed to register service ({str(e)}), retrying in 2 seconds")
             self.retrytimer = threading.Timer(2, self.RegisterService, [name, ip, port])
             self.retrytimer.start()
 
     def _RegisterService(self, name, ip, port):
-        # name: fully qualified service name
         self.service_name = '%s.%s' % (name, service_type)
         self.name = name
         self.port = port
@@ -75,8 +74,8 @@
         self.server.register_service(
             zeroconf.ServiceInfo(service_type,
                                  self.service_name,
-                                 self.ip_32b,
                                  self.port,
+                                 addresses=[self.ip_32b],
                                  properties=self.serviceproperties))
         self.retrytimer = None