Can't open usb device via webUSB

3.3k views Asked by At

I need to connect the device to the browser using the webUSB, after the connection I call the open method and this error falls "Uncaught (in promise) DOMException: Access denied.". How to fix it?

ngOnInit(): void {
    const button = document.getElementById('connectButton');
    button.addEventListener('click', async () => {
      let device;
      try {
        device = await navigator.usb.requestDevice({ filters: []});
      } catch (err) {
      }

      device.open()
        .then(() => device.selectConfiguration(1))
        .then(() => device.claimInterface(device.configuration.interfaces[0].interfaceNumber));
    });
  }
1

There are 1 answers

1
Reilly Grant On

What platform are you running on?

On Linux you will get this error if the current user doesn't have permission to open the USB device. You will need to configure a udev rule to allow the user to access it.

On Windows you will get this error if the WinUSB driver is not loaded for the device. You can use the Zadig tool to force Windows to load a particular driver for the device.

The error messages given to the site are intentionally vague. Check chrome://device-log to see more details about the error the browser encountered trying to open the device.