Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python SDK does not robustly handle BLE connection failures / drops #487

Open
epheo opened this issue Feb 17, 2024 · 4 comments
Open

Python SDK does not robustly handle BLE connection failures / drops #487

epheo opened this issue Feb 17, 2024 · 4 comments
Labels
bug Something isn't working demos Relating to demos help wanted Extra attention is needed

Comments

@epheo
Copy link
Contributor

epheo commented Feb 17, 2024

Note! This ticket will capture any and all issues relating to Python SDK BLE:

  • recovery from failures to establish connection
  • recovery from connection drops
  • closing and re-opening Wired / Wireless GoPro objecvts

In general, these use cases have not yet been designed for / tested against and I'm not sure much of this is even solvable in the Python SDK due to the lack of robustness in Bleak and the OS's BLE stack. But it needs a major investigation on each operating system.

Component
In the Python SDK.

Describe the bug
If the connection to a GoPro fails, the WirelessGoPro._periodic_keep_alive coroutine is left open.

To Reproduce
Start connection to a GoPro and have it fail (stop ble adapter or remove GoPro battery)
Then we can observe _periodic_keep_alive by checking the running coroutines:

tasks = asyncio.all_tasks()
coroutine_name = task.get_coro().qualname

Expected behavior
I would expect the keepalive to be stopped once the Connection fails.

Hardware
Hero 11
Linux 6

Additional context
I'll try to investigate later if this can be solved by initiating connection within a contextlib.AsyncExitStack().

@epheo epheo added the bug Something isn't working label Feb 17, 2024
@github-actions github-actions bot added the triage Needs to be reviewed and assigned label Feb 17, 2024
@tcamise-gpsw
Copy link
Collaborator

I've made some changes to this in the last release. However the bigger issue here is that the Wire(less)GoPro objects are not designed to persist through subsequent connections. I haven't spent much time on this because I don't think bleak robustly manages, at least on Windows, failed / reconnections.

In any case, there is a large investigation required to improve the robustness here.

@tcamise-gpsw
Copy link
Collaborator

I'm going to use this ticket as the gathering location for all BLE connection-robustness issues.

@tcamise-gpsw tcamise-gpsw changed the title WirelessGoPro._periodic_keep_alive coroutine is left running if connection failed. Python SDK does not robustly handle BLE connection failures / drops Apr 10, 2024
@tcamise-gpsw tcamise-gpsw self-assigned this Apr 10, 2024
@tcamise-gpsw tcamise-gpsw removed the triage Needs to be reviewed and assigned label Apr 10, 2024
@tcamise-gpsw tcamise-gpsw pinned this issue Apr 10, 2024
@tcamise-gpsw tcamise-gpsw added help wanted Extra attention is needed demos Relating to demos labels Apr 10, 2024
@tcamise-gpsw tcamise-gpsw removed their assignment Apr 11, 2024
@tcamise-gpsw
Copy link
Collaborator

Another symptom: BLE connection drops after provisioning COHN even though there is still a communication channel through COHN cause state management to break. We're going to need to rearchitect the entire connection scheme to be scalable for multiple connections / types.

@tcamise-gpsw
Copy link
Collaborator

tcamise-gpsw commented Aug 30, 2024

Relevent bleak ticket here: hbldh/bleak#367

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working demos Relating to demos help wanted Extra attention is needed
Projects
Status: To do
Development

No branches or pull requests

2 participants