Hello!,
I have one raspberrypi 4 running balena.os (local mode) that provides a python server that I would like to announce on the network.
As I’m using python I have set a zeroconf service using zeroconf.py and I advertise the service on the network and I’m capable of discover it with any pc using the same zeroconf.py library and a small script.
Now I would like to set a second raspberry pi (in this case a Zero one) that will run also a balena.os based deployment and it will also run a python script that in this case will try to discover the previous zeroconf service. I have used the same test code to run the zeroconf discover service that I’m using on the network and it doesn’t resolve:
from zeroconf import ServiceBrowser, Zeroconf
import ipaddress
class MyListener:
def remove_service(self, zeroconf, type, name):
print("Service %s removed" % (name,))
def add_service(self, zeroconf, type, name):
info = zeroconf.get_service_info(type, name)
print(str(ipaddress.IPv4Address(info.addresses[0])))
print("Service %s added, service info: %s" % (name, info))
if __name__ == "__main__":
zeroconf = Zeroconf()
listener = MyListener()
browser = ServiceBrowser(zeroconf, "_archerytimer._tcp.local.", listener)
try:
input("Press enter to exit...\n\n")
finally:
zeroconf.close()
I have added network_mode = host on both raspis (I already use it on the raspi4) without luck
Do I need to add anything else to the raspizero so it can discover the zeroconf?
After searching on balena forums I have found a reference to this project:
As the zeroconf.py library doesn’t use d-bus I’m thinking of switching from the it to use the dbus implementation, but the previous project shows how to expose a service but not how to discover it.
(However it is strange that the raspi 4 is capable of sucessfully expose the service on the network)…
Is there any example of how to use the d-bus to discover services?
Thank you in advance.
Gabriel