skillfed

bleak-retry-connector

A connector for Bleak Clients that handles transient connection failures

bleak-retry-connector v4.6.3 1.0M downloads/30d#4,514 on PyPI25
Permissive license MIT Active released

What it is and what it does

Bleak Retry Connector is a wrapper around the Bleak Bluetooth Low Energy client that adds automatic retry logic for transient connection failures. Instead of calling BleakClient.connect() directly, you call establish_connection() with your device and a retry count, and the library handles retries with intelligent backoff, service caching, and platform-specific workarounds. It solves common Bluetooth connection problems like timeouts on first attempt, "out of connection slots" errors on ESP32 devices, and interference from other Bluetooth operations.

The package provides BleakClientWithServiceCache, which caches GATT services to speed up reconnections, and establish_connection(), which orchestrates the retry loop and error handling. It's designed for applications that need reliable Bluetooth connectivity across different operating systems and device types, particularly where transient failures are common or connection slots are limited.

Use it for:

  • IoT applications connecting to multiple BLE devices where occasional timeouts or slot exhaustion occur.
  • Mobile or desktop apps that need to reconnect to wearables or sensors with automatic retry on failure.
  • Embedded device communication (e.g., ESP32) where connection slots are limited and retries are essential.
  • Long-running services that maintain persistent Bluetooth connections and need resilience to transient network glitches.
  • Testing or debugging Bluetooth devices where connection instability is expected during development.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Wraps Bleak's Bluetooth client with automatic retry logic and backoff to handle transient connection failures, including service caching for faster reconnections.

Yes. The package is actively maintained, has no known vulnerabilities, carries a permissive MIT license, and solves a real problem in Bluetooth connectivity. If your application uses Bleak and experiences transient connection failures, this wrapper is a straightforward drop-in that adds retry logic and service caching with minimal overhead. Install it if you need reliable reconnection handling; skip it only if your use case has no tolerance for retries or you manage reconnection logic yourself.

Install

bleak-retry-connector on PyPI

pip

pip install bleak-retry-connector

uv

uv add bleak-retry-connector

poetry

poetry add bleak-retry-connector

Installing bleak-retry-connector

Before you install

Low friction: pure Python wheel with four runtime dependencies (bleak, async-timeout, bluetooth-adapters, dbus-fast). Actively maintained as of 2026-07-22, last commit 2026-08-10.

License in practice

MIT license permits commercial and private use with minimal restrictions; attribution required.

Quickstart

pip install bleak-retry-connector

import asyncio
from bleak_retry_connector import establish_connection, BleakClientWithServiceCache

async def connect():
    client = await establish_connection(
        BleakClientWithServiceCache,
        device,
        "Device Name",
        max_attempts=3
    )
    await client.disconnect()

asyncio.run(connect())

Requires Python 3.10 or later; dbus-fast may require system dbus development libraries on Linux.

Verify before relying

  • Whether service caching persists across process restarts or only within a session.
  • Specific backoff strategy and timing between retry attempts.
  • How platform-specific quirks are detected and handled (Windows vs. macOS vs. Linux).

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 4 — async-timeout, bleak, bluetooth-adapters, dbus-fast
Maintenance actively maintained — 23 days since the last release
Last repo commit
First released
Downloads 1,010,703/month — #4,514 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: bleak_retry_connector-4.6.3-py3-none-any.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: Libraries

Tags

bluetooth connection retry logicbleak client reconnect handlerbluetooth transient failure recoveryBLE connection resilienceautomatic bluetooth reconnectbleak connection wrapperbluetooth service caching
bluetoothbleasync

More Libraries packages