question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AccessDenied when enumerating services on Windows

See original GitHub issue
  • bleak version: 0.11.0
  • Python version: 3.8.x
  • Operating System: Windows 10
  • BlueZ version (bluetoothctl -v) in case of Linux: N/A

Description

Describe what you were trying to get done.

Trying to connect to LEGO Technic hub bootloader using Bleak.

Tell us what happened, what went wrong, and what you expected to happen.

This is described in more detail at https://github.com/pybricks/pybricksdev/issues/15

The short story is that we get an AccessDenied error from GetCharacteristicsAsync() due to the fact that the device claims that it has a Service Changed characteristic that supports indications. Apparently Windows sees this and tries to automatically enable indications for this characteristic. But the device replies with an error.

This device works with Web Bluetooth on Windows, so I’m hoping that there is something in Bleak that can be tweaked.

For example, we might be able to use GetGattServicesForUuidAsync() and GetCharacteristicsForUuidAsync() instead of GetGattServicesAsync() and GetCharacteristicsAsync() to only enumerate the services and characteristics we are actually interested in.

Or we could separate out discovering characteristics from discovering services. But this would mean that this would have to be manually called by users later.

Actually, I suppose we could do all of this and keep things backwards compatible by adding a keyword argument to connect (and the object constructors for use with async with) to disable scanning for services/characteristics on connect. Then add new API to get services that takes an optional list of UUIDs as an argument. Likewise, APIs would be needed to get characteristics and descriptors with optional UUIDs. Windows and Mac have OS APIs for this, but we would probably just have to fake it on BlueZ.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dlechcommented, May 16, 2021

This happened again. I think this is the way it happened. I was using the Chrome web browser to connect to a device. Then disconnected it in the browser. Then I tried to connect to the same device with Bleak and got the AccessDenied error. After closing the web browser, I was able to connect to the device using Bleak without rebooting the computer. So, I think that the web browser was still holding on to a handle to the device somehow even though the device was no longer connected.

Also, this chromium bug mentions a similar problem. In particular, it sounds like HID services will cause an AccessDenied error since they are used by the OS. It looks like they were able to work around the issue to some extent.

0reactions
dlechcommented, Oct 6, 2021

For example, we might be able to use GetGattServicesForUuidAsync() and GetCharacteristicsForUuidAsync() instead of GetGattServicesAsync() and GetCharacteristicsAsync() to only enumerate the services and characteristics we are actually interested in.

I’m not sure this is a “solution” for this problem, but PR for this feature is #654.

In particular, it sounds like HID services will cause an AccessDenied error since they are used by the OS

Fix for this is #655

It does not seem to be anything Bleak can do to remedy this, is there?

Not sure Bleak can do anything else, so closing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to enumerate objects in the container. Access denied
1. On the root folder, right click, select properties, select security tab. · 2. Click Advanced · 3. The window that pops up...
Read more >
Failed to enumerate objects in the container. Access is denied.
I have 2 PC's side by side and one can access the other's hard drives whereas the other is being told access denied....
Read more >
"Access Denied" error on file share that has Access-based ...
Fixes an “Access Denied” issue that occurs when you try to access a file share. Occurs when you have Access-based Enumeration enabled on...
Read more >
Access is denied when using the "runas" command, Run as ...
Locate the policy: Computer Configuration\Policies\Windows Settings\Security Settings\System Services. Open the Secondary Logon service. Select ...
Read more >
Access is denied error occurs with DCPROMO - Windows Server
Discusses the Access is denied error 5 when Active Directory replications fail. This issue can occur in Windows Server 2012 R2, Windows Server ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found