Open robbiet480 opened 5 years ago
It looks like that error Error doing job: Exception in callback _SelectorDatagramTransport._read_ready()
is related to me setting up interfaces one at a time to debug, so don't worry about that one.
I won't worry ;) In any case, using this library on lo0 is probably not really useful.
@frawau Sure, but it throws a big red error message that's going to confuse our users. Can you either filter out that error message for lo0
or lower the log level from error to something not as scary?
I can also submit the PR to not throw the error on lo0
if you want.
Please do. I am one of the organisers of PyCon Thailand, and really busy right now.
I dug more into this and this is what is happening:
aiozeroconf will detect it's own broadcasted service on each interface, and for some interfaces this is adddress will be None
. Example:
ServiceInfo(type='_home-assistant._tcp.local.', name='Home._home-assistant._tcp.local.', address=None, port=8123, weight=0, priority=0, server='Home._home-assistant._tcp.local.', properties={'version': '0.94.0.dev0', 'base_url': 'http://192.168.1.234:8123', 'requires_api_password': True})
Adding an interface ban list is not going to help, as we won't know in advance which interfaces will misbehave. (I have multiple that misbehave)
This patch hides the error. I don't know if it hides an underlying issue though.
diff --git a/aiozeroconf/aiozeroconf.py b/aiozeroconf/aiozeroconf.py
index 8662c60..e1711b8 100644
--- a/aiozeroconf/aiozeroconf.py
+++ b/aiozeroconf/aiozeroconf.py
@@ -2068,7 +2068,8 @@ class Zeroconf(QuietLogger):
out.add_answer(msg, DNSText(
question.name, _TYPE_TXT, _CLASS_IN | _CLASS_UNIQUE,
_DNS_TTL, service.text))
- if question.type == _TYPE_SRV:
+ if (question.type == _TYPE_SRV and
+ service.address is not None):
out.add_additional_answer(DNSAddress(
service.server, _TYPE_A, _CLASS_IN | _CLASS_UNIQUE,
_DNS_TTL, service.address))
Hi Paulus,
I had a look, and I am still not entirely sure what is going on. But I think I have a simple workaround.
Do something like
info = ServiceInfo(ZEROCONF_TYPE, zeroconf_name, address=b"", port=8123, properties=params)
For services you register. Just adding the address with an empty byte string.
I think it has to do with the fact that when receiving a "A" or "SRV" query, it should respond with the address of the interface on which the query was received, and that should be provided in the ServiceInfo.
But I am not entirely sure....
Regards, François
If I add an empty byte string, I end up breaking a zeroconf consumer that I had running, which is trying to convert the address to an IP address using the ipaddress
package in Python. So I think that it is a good indicator that passing an empty byte string is not a good idea.
I noticed this PR on python-zeroconf in which they behave the same as with my diff above: not forward any DNSAddress.
I don't know enough about zeroconf specifics, but isn't it weird that the code registering a service needs to know the IP address on each interface ?
From the look of it, that PR adds "addresses", a list, and creates a record for each address in the list. But it does look that you still have to provide the addresses when creating the ServiceInfo.
I don't disagree with you, we should be able to automatically add the address of the interface that advertises the service. I did not work with this code for quite some time, and I am busy with PyCon Thailand (remember? I did ask you uf you could be a keynote). Hopefully I will find sometime this WE.
Cheers
remember? I did ask you uf you could be a keynote
I remembered when I saw you mentioned it the first time 👍 Good luck with the conference !
Hi,
I have a test version in branch dev_ha. This handles multiple A and AAAA records. When publishing a service, if no address is specified, it will add A and AAAA records for all the addresses of all the interfaces being used.
Be sure to read the commit message. Breaking change.
Let me know how it works.
Regards, François
I initialize
aiozeroconf
like this:I get this error upon launching (I slightly changed the
Zeroconf.initialize
function to set up interfaces one by one to isolate what went wrong):[aiozeroconf.aiozeroconf] initializing comm af 30 on interfaces ['lo0']: [Errno 49] Can't assign requested address
.Shortly after startup I get these errors too:
I'm on macOS 10.14.4.