-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error enabling device tracker #22
Comments
Welcome! How many devices roughly would you say are on your network? |
Just did a quick check of current dhcp leases, and it is showing about 180. |
Ok. Are you comfortable manually editing files of the integration by chance? |
Sure! |
Change |
Worked!! Thank you so much for the quick response, especially on new years' day! Wishing you a very happy new year! |
One small feature request - would it be possible to sort the devices to track list by either the mac address or (preferably) the IP? As I have so many devices, it would make it easier to find the required devices. Not a big issue, so only if you have time. Thanks again! |
Hi again Unfortunately I seem to be having another issue. After adding 1 device in the device tracker list, the There are other debug messages in the log from opnsense that seem normal, e.g. Appreciate your help again. Thanks. EDIT: All the entities (including the non-device_tracker ones) are now also showing as |
Yeah that was somewhat expected. Change this to False as well.. |
That seems to have done the trick! Thanks again. |
That flag tells the api to not resolve hostnames with arp table entries. So something about that in your setup is adding significant delay to the process as a whole. |
Yes, I had figured that that was the case. Do you have any ideas as to what might be causing this delay? I'm assuming it is not normal...? |
It’s expected to take a little extra but it seems in some cases something is hanging somewhere. Others have experienced the same issue so you aren’t alone. |
Ok, good to hear that it is not just me! Appreciate all your help. |
Want to leave this open for a bit. Can you try these 2 commands at the cli of opnsense and see how long they take?
|
Sure.
|
Well that's a bit crazy, the 1st is what gets executed when the value is set to |
Are you sure about that? With the first one, I am seeing hostnames in the json (e.g |
That is correct, when I glanced at the code I missed the In any case, both seem to be returning incredibly fast, I wonder why it would cause such a headache when trying to use that option via the api.. |
Can we benchmark that through time+curl just to see the delay? |
Not very easy no, but plopping a file on the hass filesystem shouldn’t be terrible. I’ll send an example when I get back to my desk. |
If it helps, the first one (with the hostnames) is taking about 15 seconds in real life (even though 'real' value is showing 0.005u). The data comes in spurts - i.e. about a third of the data comes through, then it pauses for a few seconds, then another splurge of date, pause etc. Is something timing out on the pauses? |
Ah ok, so the real time is the 3rd value (15.20)? |
Yes, I think so. Reading the FreeBSD man page, the 3rd value is apparently the system time (the 1st being 'real' time), so not quite sure how to interpret this! I used a separate stopwatch to reconfirm though, and yes, the actual elapsed time on the stopwatch appears to be the 3rd value (varies from 10 seconds to 15 seconds per run). |
Ok well name resolution is done via standard nsswitch semantics from what I can tell so it sounds like some 5s timeout is getting hit 2 or 3 times. We may need to strace the call or something to see where it’s getting stuck. |
I just realised what the cause of the slow down is.... I have Adguard in the middle which then forwards on to Unbound. Taking Adguard out of the equation, the same command now returns all the hostnames almost instantly: Apologies for wasting your time on this... |
I have the same setup...AGH then unbound. We're talking about reverse lookups, right? Unless you have many filters/lists, it shouldn't take 15s. You could try disabling some lists/filters until you find the cause of the delay. |
Definitely not wasted time! This is great debugging going on so thanks for the help! Others have reported the same or similar issues so this has been extremely helpful. Let’s see if we can figure out what exactly in adguard is causing the delay and perhaps we can mention this issue in the README and possibly give advice on configuring adguard in an agreeable manner. |
Thanks for confirming that you have the same set up and yours is working fine. This being the case, I just went through trying each option on Adguard (I didn't have many filter running earlier) and have found the culprit!
It was not the number of filters, but the default rate limit on Adguard. This was set to 20. Disabling it by setting to 0 solves the bottleneck and we are getting results returned in fractions of a second ( All good now :) Thanks again. |
I was wondering about exactly that given the 5s intervals! Very good! We’ll document. In the mean time I’ll reach out to others who are potentially seeing the same issue and see if we have some matches. |
It will be interesting to hear if theirs is the same issue. Would you like me to close this issue now, or leave it open a bit longer? |
Defaults of a critical service like AGH should be carefully chosen by devs. I remember it was one of the first parameters whose defaults I didn't like... Glad you sorted this out. It's a good catch in case someone else has the same issue. |
Let’s leave it open until it’s been documented etc. |
When you see a fixed pattern, it's not a bug, it's by design. It was basically a throttle. :) |
Yes, that's what it felt like.
Sure. |
This debugging experience is the main reason why I love the open-source philosophy/approach. Great teamwork of people giving their time/experience for free with the sole scope of solving issues and learning new things while doing it... I was not an advocate of open-source a few years ago...I was totally wrong...obviously... |
Yes, absolutely! |
If it works so good, I might enable device_tracker too. The ones I tried in the past didn't leave me confident, but Travis is a very good developer, I might give it another shot. :) |
It seems to be working well on my system (even without the hostnames earlier).
Yes, very much so! |
Everyone helps! The device tracker integration in this integration is quite unique in that I have direct control over the arp table and remove the entries. As long as you set the scan interval and consider home interval to sane values you should get very consistent and good results. |
Could be worth a note about recommended values/defaults in the docs. I'll definitely follow your recommendations. BTW Travis, I opened an issue yesterday, don't know if you saw it. No urgency obviously... |
The values are personal preference for sure, but 30s and 300s (scan ever 30s and consider home for 5 minutes) or 60s and 600s seems like decent starting points. |
Thanks. I'll try those...the scanning frequency is in addition to the component's polling for status info, correct? |
The device tracker scans are in addition and are on an entirely separate scan interval from the main scans. Both loops collect distinct data points however. |
Got it. Thanks. |
@smar000 this issue can be closed right? :) or maybe @travisghansen wants to keep it open for others with similar issues... |
I had closed it earlier but @travisghansen wanted it to keep it open for a bit. |
Yeah I’ll add some notes in the docs as discussed. |
Note has been added to README.md about AdGuard. |
I would recommend adding "Home" to end of "AdGuard" in the readme. I had to read through this to figure out it was AGH, not one of the other apps/services that are called AdGuard something or simply just AdGuard. |
updated README |
Hey @travisghansen, I got an error too when trying to activate the device tracker feature. I have Adguard Home installed on the opnsense and your opnsense plugin. My unbound listens at the port 5353 and adguard on 53. When I disable adguard and set the unbound port to 53 (so unbound works on its own, standalone) and I activate the device tracker in opnsense configuration it works instantly without errors. But when trying to do the same with adguard activated AND rate limit is set to 0 it does not work unfortunately. I tried your fix #22 (comment) |
The trouble is when it resolves hostnames it does so for every entry in the arp table. If the DNS system used doesn't like the rate or chokes it will fail. I'm not super-excited about disabling the hostname lookup as the user experience for that generally is not great :( Does it log errors to the console by chance? If so send them over. |
Here is the output from the HA logs: `This error originated from a custom integration. Logger: aiohttp.server Error handling request EDIT: When using dnsmasq DNS I get the same error when trying to enable device tracker. |
Hi @travisghansen
Many thanks for this plugin. I have installed it (along with the corresponding opnsense plugin) and am getting the non
device_tracker
entities coming through, as expected.However, wen trying to save after clicking "Enable Device Trackers" in the configuration options, I get a socket timeout error:
Saving other configuration options (e.g. Scan Interval) works fine. The issue only appears with enabling device trackers.
I have tried repeatedly (including restarting opnsense/home assistant etc), but the error persists. I am using OPNSense version 21.7.7 and Home Assistant 2021.12.7.
Can you help by pointing me in the right direction to enable device trackers.
Many thanks!
EDIT: I am using root user to login to OPNsense.
The text was updated successfully, but these errors were encountered: