-
Notifications
You must be signed in to change notification settings - Fork 304
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
Windows10 - Timeout Exception Raised while connecting #604
Comments
Have you tried the suggested troubleshooting? https://bleak.readthedocs.io/en/latest/troubleshooting.html |
I will try it right now. |
In the morning I got the timeout exception on disconnecting, while using the service explorer example. Using cached doesn't seem to interfere since I got the error in both cases(true or false). I tried to make sense when using Wireshark, but i didn't know what i was looking for. Thank you very much, please let me know if there's something more I can do. Stacktrace of the disconnect, service explorer
|
Try replacing if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.set_debug(True)
loop.run_until_complete(run(ADDRESS, True)) with if __name__ == "__main__":
asyncio.run(main(ADDRESS, True)) |
Same result |
I guess we need to add some more logging to figure out where the problem is. |
I also encountered the same problem.
|
This is a tough one. Setting On the disconnect side of things, the device might not disconnect if something else in the OS is using the device, so that could be causing the timeout that was observered there. |
I'm not using cached. I have been testing the solution @linweifu came up with, but for me it didn't work. |
I'm having the same problem. Code that worked in python 3.7 bleak 0.6.1 windows 10 (like 1903 or so) no longer works in python 3.9 bleak 0.12.1 windows 10 20H2. (I'm picking up an old project again and haven't tried anything inbetween). The Get Model Name demo in the README also no longer works. In both cases I just get timeout errors. However! Following on from @linweifu I instead commented out the |
I've pushed a bunch of changes to the WinRT backend and to the example code to the develop branch over the past couple days. Can everyone please test again using that branch? |
I had the same issue with a fresh install from pip today and resolved with the solution from @TomatoCo |
Does that mean Bleak v0.13.0? |
Yes |
Do we have any update on this issue? I am still getting the timeouts on Windows10 with github example connect_by_bledevice. the performance is not consistent. Out of 15 attempts I am able to make connection and read services only for once. Behavior is same even with bigger timeouts. |
On Windows, you might have better luck using |
Hello David,
Thanks for quick reply. But I am wondering is the issue with Bleakscanner? I am always getting the scanned devices correctly. Issue is mainly observed while creating “client”. I tried with both the ways,
async with BleakClient(device) as client:
or
BleakClient(device) as client & client.connect()
But in both the ways I am unable to connect to the client. I tried with longer timeouts (50Sec). Out of 15 tries, I am able to connect only once. Thus I think the connection is unstable.
Are you suggesting to run Bleakscanner in parallel while connecting with the device? Atleast the example code does not say so.
Thanks,
Rohan
|
It doesn't look like anyone has done any Bluetooth packet logging on this yet. Usually that offers insight into what is going on under the hood. https://bleak.readthedocs.io/en/latest/troubleshooting.html#windows-10 You could also try #680 to see if it makes a difference. |
Hi, I stopped seeing this error for a long time but now it surfaced again. |
In the capture, it looks like Windows never attempts to connect to the device. There are only scanning packets. Does it fix the problem if you reboot your computer? |
I rebooted both devices, the problem persists. |
have you tried bleak 0.14.2? |
Not yet no. I will update both versions. |
I rebooted after the update and it started working again. |
Hello all! I am dealing with this issue myself and I was hoping there may be more insight on this issue a year later. I am using a Windows 10 laptop, with Python 3.9, Bleak 0.14.2 and Bleak Win-rt 1.1.1. Whenever I try to run this basic code below, I also receive this same error:
and here is the error'ed output that I recieve:
I tried what was suggested by Linweifu, but I do not have a dotnet folder in my backends folder, just:
If any more info is required, please let me know, as I am certainly glad to help! |
python 3.9.7; Bleak 0.14.3; Windows 10: same error!
|
Has anyone tried making the timeout longer? Has anyone tried logging Bluetooth packets? |
I will capture packets on my end and upload that, and hopefully that provides some insight. I have tried making the timeouts longer but it unfortunately didn't change the erroneous behavior. |
Can you attach the log so we can see the actual data? |
From the log above, we can see that Windows is telling the Bluetooth chip to scan with a filter policy set to 0x01 as expected for connecting. However, there is not command to set the filter list. Here is an example of such a command that I captured on my Mac. So, my guess is that there is a problem with the Bluetooth driver on Windows. I would check for driver updates or try a different Bluetooth adapter that uses a different chipset. |
It actually works on linux for me so I guess there's a windows problem here. Tried with updating my bluetooth driver but I still get the timeout error /: |
Some devices will get a TimeoutError when trying to connect because setting `self._session.maintain_connection = True` is not enough to trigger a connection to the device. We also have to start an interaction with the device. This can be done by calling `self.get_services()` which we need to do here anyway. This also make `get_services()` be included in the timeout, which is probably a good thing. Fixes: #604
I'm having the same TimeOut issue. My script works perfectly fine on the Windows desktop I set up a few months ago, but today I tried running it on a new Surface Go device with 3.11.0 Python, and it's not working. Scanner example script works fine, but can't connect to my device.
|
This issue has been closed. Please start a new issue and include all requested info like Bleak Version, OS version, Bleak debug logs, Wireshark logs, Bluetooth adapter chipset and driver info. |
Some devices will get a TimeoutError when trying to connect because setting `self._session.maintain_connection = True` is not enough to trigger a connection to the device. We also have to start an interaction with the device. This can be done by calling `self.get_services()` which we need to do here anyway. This also make `get_services()` be included in the timeout, which is probably a good thing. Fixes: hbldh#604
Description
I'm trying to run the "service_explorer" example script.
It's a regular crash, doesn't happen every time the script is executed but when it happens it persists on the next executions.
What I Did
I have tried to increase the timeout in the BleakClient() constructor to 120 seconds but I get same error.
I also tried to connect to NRF Connect Android app just to make sure that it wasn't some bad configuration on my GATT Server( which is in a Xamarin Application).
StackTrace
Thank you!
The text was updated successfully, but these errors were encountered: