Welcome to Bleak Retry Connector documentation!
Installation & Usage
Project Info
- CHANGELOG
- v3.10.0 (2025-04-01)
- Updates
python-semantic-release/python-semantic-releasefrom 7.34.6 to 9.21.0 - Release notes - Changelog - v3.9.0 (2025-02-20)
- v3.8.1 (2025-02-04)
- v3.8.0 (2025-01-21)
- v3.7.0 (2025-01-18)
- v3.6.0 (2024-10-05)
- v3.5.0 (2024-04-10)
- v3.4.0 (2024-01-01)
- v3.3.0 (2023-10-25)
- v3.2.1 (2023-09-14)
- v3.2.0 (2023-09-14)
- v3.1.3 (2023-09-07)
- v3.1.2 (2023-09-03)
- v3.1.1 (2023-07-25)
- v3.1.0 (2023-07-19)
- v3.0.2 (2023-03-25)
- v3.0.1 (2023-03-18)
- v3.0.0 (2023-02-25)
- v2.13.1 (2023-01-12)
- v2.13.0 (2022-12-23)
- v2.12.1 (2022-12-22)
- v2.12.0 (2022-12-22)
- v2.11.0 (2022-12-22)
- v2.10.2 (2022-12-12)
- v2.10.1 (2022-12-05)
- v2.10.0 (2022-12-05)
- v2.9.0 (2022-12-03)
- v2.8.9 (2022-12-02)
- v2.8.8 (2022-12-02)
- v2.8.7 (2022-12-02)
- v2.8.6 (2022-11-30)
- v2.8.5 (2022-11-19)
- v2.8.4 (2022-11-11)
- v2.8.3 (2022-11-06)
- v2.8.2 (2022-11-01)
- v2.8.1 (2022-10-31)
- v2.8.0 (2022-10-31)
- v2.7.0 (2022-10-30)
- v2.6.0 (2022-10-30)
- v2.5.0 (2022-10-29)
- v2.4.2 (2022-10-24)
- v2.4.1 (2022-10-24)
- v2.4.0 (2022-10-24)
- v2.3.2 (2022-10-22)
- v2.3.1 (2022-10-18)
- v2.3.0 (2022-10-15)
- v2.2.0 (2022-10-15)
- v2.1.3 (2022-09-26)
- v2.1.2 (2022-09-26)
- v2.1.1 (2022-09-26)
- v2.1.0 (2022-09-26)
- v2.0.2 (2022-09-25)
- v1.17.3 (2022-09-24)
- v1.17.2 (2022-09-23)
- v1.17.1 (2022-09-15)
- v1.17.0 (2022-09-15)
- v1.16.0 (2022-09-14)
- v1.15.1 (2022-09-13)
- v1.15.0 (2022-09-12)
- v1.14.0 (2022-09-11)
- v1.13.2 (2022-09-11)
- v1.13.1 (2022-09-11)
- v1.13.0 (2022-09-10)
- v1.12.3 (2022-09-10)
- v1.12.2 (2022-09-10)
- v1.12.1 (2022-09-10)
- v1.12.0 (2022-09-10)
- v1.11.1 (2022-09-10)
- v1.11.0 (2022-08-20)
- v1.10.1 (2022-08-19)
- v1.10.0 (2022-08-19)
- v1.9.0 (2022-08-19)
- v1.8.0 (2022-08-15)
- v1.7.2 (2022-08-12)
- v1.7.1 (2022-08-12)
- v1.7.0 (2022-08-11)
- v1.6.0 (2022-08-11)
- v1.5.0 (2022-08-08)
- v1.4.0 (2022-08-05)
- v1.3.0 (2022-08-04)
- v1.2.0 (2022-08-03)
- v1.1.1 (2022-08-02)
- v1.1.0 (2022-07-24)
- v1.0.2 (2022-07-22)
- v1.0.1 (2022-07-22)
- v1.0.0 (2022-07-22)
- v0.1.1 (2022-07-22)
- v0.1.0 (2022-07-22)
- v0.0.1 (2022-07-22)
- Contributing
Bleak Retry Connector
A connector for Bleak Clients that handles transient connection failures
Installation
Install this via pip (or your favourite package manager):
pip install bleak-retry-connector
Usage
Quick Start
Replace your direct BleakClient.connect() calls with establish_connection() for automatic retry logic and better error handling:
import asyncio
from bleak import BleakScanner
from bleak_retry_connector import establish_connection, BleakClientWithServiceCache
async def connect_to_device():
# Find your device
device = await BleakScanner.find_device_by_address("AA:BB:CC:DD:EE:FF")
if device is None:
print("Device not found!")
return
# Establish connection with automatic retry logic
client = await establish_connection(
BleakClientWithServiceCache, # Use BleakClientWithServiceCache for service caching
device,
device.name or "Unknown Device",
max_attempts=3 # Will retry up to 3 times with backoff
)
try:
# Use the connected client normally
services = client.services
print(f"Connected! Found {len(list(services))} services")
# Read a characteristic
value = await client.read_gatt_char("00002a00-0000-1000-8000-00805f9b34fb")
print(f"Read value: {value}")
finally:
await client.disconnect()
# Run the example
asyncio.run(connect_to_device())
Why Use bleak-retry-connector?
Automatic Retry Logic: Handles transient connection failures automatically
Intelligent Backoff: Uses appropriate delays between retry attempts
Service Caching:
BleakClientWithServiceCachecaches services for faster reconnectionsBetter Error Messages: Provides clear, actionable error messages
Platform-Specific Handling: Manages quirks across different operating systems
Connection Slot Management: Handles limited connection slots on some devices
Common Connection Issues This Solves
Device not found errors that resolve on retry
Connection timeouts on first attempt
“Out of connection slots” errors on ESP32 devices
Interference from other Bluetooth operations
Platform-specific connection quirks
For detailed documentation and advanced usage, see the full documentation.
Contributors ✨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Credits
This package was created with Cookiecutter and the browniebroke/cookiecutter-pypackage project template.