trympet / homebridge-volvo

Volvo plugin for Homebridge
https://npm.im/homebridge-volvo
Apache License 2.0
26 stars 6 forks source link

Excessive dns requests #9

Open snufk1ns opened 4 years ago

snufk1ns commented 4 years ago

Hi, thank you for this plugin, really good. 👍🏻

I’ve noticed that the plugin is hammering the dns server with new queries all the time (vocapi.wirelesscar.net). About 45K/day. Is this really necessary?

trympet commented 4 years ago

Hi, thanks!

At the moment, since I am using node-fetch, http sockets are not durable. This means that a new TCP connection is created upon every request, along with a corresponding DNS request. However, on most deployments, this should not be a problem, as most operating systems cache DNS records locally by default; on Debian: systemd-resolved.

One option would be to use a persistent connection with keep-alive (if the VOC API supports it). This requires the fetch API to be swapped out with the node-http API.

Another option would be to modify the update interval in the config.

Despite this, 45k req/day is still abnormal, since two requests at 10s (default) intervals would only add up to ~20k req/day. Feel free to dig though the source code if you want. I'll try to have a look and see if I can spot something.

snufk1ns commented 3 years ago

Just FYI - I had to disable this plugin.

While enabled and working fine. It drained the battery on both my cars in about 10 days. Not sure if its frequent polling that keeps the system in the car active for longer or what. As soon as I disable this plugin, the battery in the cars last for much longer. ( I use a CTEK battery monitoring to check status).