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

Exception trying to discover services. #172

Closed
whoopsmith opened this issue Mar 23, 2020 · 8 comments
Closed

Exception trying to discover services. #172

whoopsmith opened this issue Mar 23, 2020 · 8 comments
Assignees
Labels
Backend: BlueZ Issues and PRs relating to the BlueZ backend

Comments

@whoopsmith
Copy link

  • bleak version: Version 0.6.1
  • Python version: Python 3.6.9
  • Operating System: Linux Ubuntu 18.04.4
  • BlueZ version (bluetoothctl -v) in case of Linux: bluetoothctl: 5.48

Description

Trying to learn how to use this project by playing around.
I'm scanning for devices and trying to discover services.

I have combined the discover example with the service_explorer example. I discover all the devices and then feed each of those to the service_explorer code.

Sometimes I get a list of services but sometimes get the exception below. Is this expected?

What I Did

Scanning: ED:E4:C8:1D:86:45 
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/bleak/backends/bluezdbus/client.py", line 144, in connect
    ).asFuture(self.loop)
txdbus.error.RemoteError: org.bluez.Error.Failed: Software caused connection abort

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./get_whoop.py", line 80, in <module>
    loop.run_until_complete(service_explorer(address, loop, True))
  File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
    return future.result()
  File "./get_whoop.py", line 40, in service_explorer
    async with BleakClient(address, loop=loop) as client:
  File "/usr/lib/python3.6/asyncio/coroutines.py", line 129, in throw
    return self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.6/dist-packages/bleak/backends/client.py", line 44, in __aenter__
    await self.connect()
  File "/usr/lib/python3.6/asyncio/coroutines.py", line 129, in throw
    return self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.6/dist-packages/bleak/backends/bluezdbus/client.py", line 146, in connect
    raise BleakError(str(e))
bleak.exc.BleakError: org.bluez.Error.Failed: Software caused connection abort
@hbldh hbldh self-assigned this Mar 27, 2020
@hbldh hbldh added the Backend: BlueZ Issues and PRs relating to the BlueZ backend label Mar 27, 2020
@hbldh
Copy link
Owner

hbldh commented Mar 27, 2020

It is not expected and this is the first time I have seen this issue.

I will not look at this in the foreseeable future I am afraid. I am swamped with other (paid) work and cannot guarantee doing anything with this project for quite some time. I will still address PRs to develop branch occasionally, so if you desire these changes you have to do the legwork yourselves.

@whoopsmith
Copy link
Author

Great. Thank you for the response. I don't mind digging in and figuring out whats going on. That will be a great way to learn more about how it works.

Now that I know its not expected I'll drill down and see what I can find. Like you my day job calls me away but the device(s) I'm trying to connect to are part of my day job so I can justify some paid time to investigate.

@corvis
Copy link

corvis commented Apr 14, 2020

Hey @whoopsmith,

Have you solved your issue? It seems I have the similar one - from time to time when I call connect method I got org.bluez.Error.Failed: Software caused connection abort error. And this happens really randomly.

I implemented retry logic which tries to reconnect again and again when this happens. Sometimes it connects from the first attempt quickly, sometimes it takes 2-3 attempts and sometimes 7-8. Basically this makes my software pretty unstable and super slow.

So any insight on the root cause will be highly appertained.

@hbldh
Copy link
Owner

hbldh commented Jun 2, 2020

There was quite a long discussion about this in #94. See if anything there helps.

This repo also had issues with this some years ago. The accepted solution seems to be to restart the bluetooth adapter...

@ArthurKun21
Copy link

Hi @whoopsmith and @corvis did you resolved this issue? I am also experiencing this issue at raspbian and my bluez is already at 5.50

@corvis
Copy link

corvis commented Aug 26, 2020

@RulerKun unfoirtunately no. It still happens randomly, for some people (combination of hardware and software) it happens more often then for others. The recent example is here: corvis/prana_rc#1 (comment) the guy has raspbian and uses embedded rpi adaptor.

@hbldh
Copy link
Owner

hbldh commented Sep 2, 2020

I have no news for you regarding this. It might be alleviated if #236 is worked on. It might be due to txdbus and how it handles the DBus connections.

@dlech
Copy link
Collaborator

dlech commented Jul 26, 2022

There are newer issues where people have reported the same "Software caused connection abort" error, so let's close this one as a duplicate.

@dlech dlech closed this as completed Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend: BlueZ Issues and PRs relating to the BlueZ backend
Projects
None yet
Development

No branches or pull requests

5 participants