question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bleak.exc.BleakDBusError: [org.bluez.Error.Failed] le-connection-abort-by-local

See original GitHub issue
  • bleak version: 0.16.0
  • Python version: 3.10
  • Operating System: Home Assistant docker container Linux homeassistant 5.15.32-v8 #1 SMP PREEMPT Tue Aug 16 14:52:58 UTC 2022 aarch64 Linux
  • BlueZ version (bluetoothctl -v) in case of Linux: 5.64

Description

Cant connect to device

What I Did

import asyncio
import binascii
import uuid
from bleak import BleakClient, BleakScanner
from bleak.exc import BleakError

MAC = "00:A0:50:82:75:CA"
NAME_CHARACTERISTIC = '00002A00-0000-1000-8000-00805F9B34FB'
GENERAL_SERVICE = '00001801-0000-1000-8000-00805f9b34fb'

async def main(ble_address: str):
    device = await BleakScanner.find_device_by_address(ble_address, timeout=20.0)
    async with BleakClient(device) as client:
        services = await client.get_services()
        print("Services:")
        for service in services:
            print(service)
        value = bytes(await client.read_gatt_char(uuid.UUID(NAME_CHARACTERISTIC))).decode('utf-8')
        print(value)

asyncio.run(main(MAC))

The stack-trace is:

Traceback (most recent call last):
  File "/config/./debug_bleak.py", line 29, in <module>
    asyncio.run(main(MAC))
  File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/config/./debug_bleak.py", line 21, in main
    async with BleakClient(device) as client:
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/client.py", line 61, in __aenter__
    await self.connect()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 167, in connect
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 24, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] le-connection-abort-by-local

Same code at the native Linux works correctly

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:20 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
deepcodercommented, Oct 21, 2022

Same issue on x86 Ubuntu 22.04.1

user@quieter3-01:~/bleak-ble$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"
user@quieter3-01:~/bleak-ble$ uname -a
Linux quieter3-01 5.15.0-52-generic #58-Ubuntu SMP Thu Oct 13 08:03:55 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
user@quieter3-01:~/bleak-ble$ bluetoothctl -v
bluetoothctl: 5.64
user@quieter3-01:~/bleak-ble$ pip3 show bleak
Name: bleak
Version: 0.19.0
Summary: Bluetooth Low Energy platform Agnostic Klient
Home-page: https://github.com/hbldh/bleak
Author: Henrik Blidh
Author-email: henrik.blidh@nedomkull.com
License: MIT
Location: /home/user/.local/lib/python3.10/site-packages
Requires: async-timeout, dbus-fast
Required-by:
0reactions
bdracocommented, Oct 31, 2022

When my RTL8761BU based ZEXMTE BT-505 gets overloaded I get this error.

I replaced it with a Feasycom FSC-BP119 which is CSR8510A10 and seems to handle the bluetooth density quite a bit better.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[org.bluez.Error.Failed] Software caused connection abort
Failed ] Software caused connection abort or This service is already present in this BleakGATTServiceCollection! When I exit the program, I get ...
Read more >
Bluetooth connection error while using bleak in raspberrypi 400
I am using raspberry pi 400 and I using bleak python module to ... bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Input/output error
Read more >
Error when trying to connect to bluetooth speaker: `org.bluez ...
I was trying to pair my magic keyboard and it was failing with "Failed to connect: org.bluez.Error.Failed" no matter what I tried. Only...
Read more >
Controlling nRF52840 Express Feather from Raspberry Pi
Adafruit CircuitPython supports using Bluetooth Low Energy (BLE) to communicate ... bleak.exc.BleakDBusError: org.bluez.Error.NotPermitted
Read more >
BLE Characteristic Read failed with ATT error - Apple Developer
Client App - An external device works with bluez; iOS peripheral app register a Gatt Service with 1 characteristic; external client device connect...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found