getsenic / gatt-python

Bluetooth GATT SDK for Python
MIT License
318 stars 86 forks source link

Occasional large delays when connecting to multiple peripherals #44

Open Snevzor opened 5 years ago

Snevzor commented 5 years ago

Using Bluetoothctl I can connect to 3 peripherals in parallel without additional delays. So one connection takes 3-6 seconds (we have some really constrained connection parameters on our peripherals) and for 3 peripherals it still takes 3-6 seconds per connection.

With gatt-python we're seeing extreme large delays but not always... . For instance on an average of 10 connect/disconnect cycles with 3 peripherals: Average total connection duration 135.988185 seconds with a min/max value of 8/263.836915 seconds. So sometimes it only takes 8 seconds but it can also take 263 seconds. Very inconsistent and hard to debug.

I presume it's rather D-Bus related or perhaps gatt-python performs some additional load on D-bus?

I'm struggling really hard to debug this because when waiting for 200+ seconds on an connect_xxx callback there are no entries in bluetoothd and dbus-monitor logs. So the system hangs and there is not a single indication of why this is happening.

Snevzor commented 5 years ago

I can't really tell by looking at the gatt-python source code, but could this be related?

https://github.com/adafruit/Adafruit_Python_BluefruitLE/issues/11

Machoney commented 4 years ago

Hi, any update in this issue? I'm struggling with the same problem.