I'm using the HomeAssistant Amcrest integration, and my OPNsense router was showing 10000's of queries for my camera DNS names. My cameras have static DHCP assignments, which puts the hostname in Unbound with a 3600s TTL. I expected to see maybe 100 queries per day, but HA was generating ~300 queries per second to the camera names. Changing my HA config to IP addresses solved the problem, and I'm not seeing constant queries.
I thinkrequests is triggering a new DNS lookup every time through this function/loop (i.e. for every single command):
I'm using the HomeAssistant Amcrest integration, and my OPNsense router was showing 10000's of queries for my camera DNS names. My cameras have static DHCP assignments, which puts the hostname in Unbound with a 3600s TTL. I expected to see maybe 100 queries per day, but HA was generating ~300 queries per second to the camera names. Changing my HA config to IP addresses solved the problem, and I'm not seeing constant queries.
I think
requests
is triggering a new DNS lookup every time through this function/loop (i.e. for every single command):https://github.com/tchellomello/python-amcrest/blob/master/src/amcrest/http.py#L290-L304
Caching the
session
between calls might help, but I'm not enough of arequests
expert to be certain.