Bluetooth integration scans for 1 hour non-stop

Hello everyone
I often have Bluetooth problems, on the presence: one day everything works fine two users present (some absences of the order of 2 to 3 minutes) and days like today: users absent and no refresh (there absent for 1 day).
Moreover in the discovery of Bluetooth objects, when I start a search (in the integration), it searches permanently (I left it searching for 1 hour and if I don’t stop it it would still be searching). I no longer have control to trigger the presence scanner either.
Do you have any idea where this might come from?
thanks

Bluetooth was indeed blocked the search ran for at least 2 hours (I forgot it :upside_down_face:)
After restarting all containers, Bluetooth started again, until next time :grinning:

Hi @Psoy,

For Bluetooth, we use a library called Noble, which is known to be unstable. We do our best to make it work with what we have :smiley:

If you have specific error logs, we can help. Don’t hesitate if it happens again to inspect the logs and come back here with the error message if there is one.

Thanks for your answers, I will monitor that

Hello Pierre Gilles,
the problem has happened again, what should I look for in the logs? There are lines I understand, but others I don’t. It’s to avoid sending 5 pages of logs.
Thank you.

Something that looks like an error, usually you have a log level on the left of each log which can be or in case of error.

If in doubt, you can send me everything if you want, on a pastebin (https://pastebin.com/) for example :slight_smile:

Thanks Pierre Gilles
I can send it to you by email, as I made a txt file, before and after restarting Gladys

If you want!

I didn’t find anything special in the logs, but there’s something that catches my attention:

2022-03-23T08:25:32+0100 <error> index.js:21 (process.<anonymous>) Error: bind EADDRINUSE 0.0.0.0:9898
    at dgram.js:357:20
    at processTicksAndRejections (internal/process/task_queues.js:83:21) {
  errno: -98,
  code: 'EADDRINUSE',
  syscall: 'bind',
  address: '0.0.0.0',
  port: 9898
}

This log has nothing to do with the Bluetooth integration (it’s the Xiaomi integration), but it means that you potentially have multiple instances of Gladys running on the same machine? Is that the case?

For Bluetooth, you can’t have multiple programs using it at the same time, so if you have any other program running at the same time that uses Bluetooth, it prevents Gladys from using Bluetooth

However, when you say « Bluetooth scans for 1 hour non-stop », how do you know that?

Hello Pierre-Gilles

I no longer have anything on the Xiaomi integration. How can I check if I have multiple Gladys instances?
When I do a docker ps, only one Gladys instance is displayed.

When I start a Bluetooth search, the search circle keeps spinning without finding anything (I say more than an hour, because the other day, I left it searching and an hour later, it was still running) and moreover, the presence scanner no longer reacts. On the dashboard:

When I « restart » Gladys, everything returns to normal.

docker ps is sufficient. I just wanted to check if you accidentally launched other Gladys containers to test dev versions, for example.

Ok, actually, Bluetooth has a 5s timeout in the integration, so anyway after 5 seconds if it’s still running it’s just that it didn’t work, it doesn’t run for 1h :slight_smile:

On the browser side, you can check the browser logs when you do the faulty scan if you have a specific error? Right-click on the page => Inspect element => Console / Network.

I ping @AlexTrovato, he’s the one who coded this integration!

For now, I no longer have the bug, I’ll do that as soon as I get it again.
Thanks again

Hello Pierre Gilles
Here’s what I see in the browser logs. I’m on Chrome now (I hope this is what you asked for)


There’s not much on Firefox

The Bluetooth bug occurs on both browsers.
Have a good day

Not really, I think the log was already there before, it’s a normal log :slight_smile:

After all, if there are no browser logs, the issue might not be there.

I’m a bit stuck now… I’m far from being an expert on this integration, and without a specific error log, it’s hard to help, I admit ^^

Hello Pierre-Gilles
I will try to dig deeper, see if, when I connect objects, the fault occurs or not. If I find something, I will repost.
Thanks for your follow-up
Have a nice day

Hello, I’ve been following this discussion « from afar », is it still relevant?

Hello @ AlexTrovato
Yes, unfortunately, it’s still current and I have the problem right now. I restart Gladys and it works again and then it crashes.