Wajahath
Wajahath

Reputation: 4058

WebUSB: device.open() on any device causing "Failed to execute 'open' on 'USBDevice': Access denied"

I'm playing with a thermal printer to work with WebUSB.

Here is the minimal Glitch demo (please note this demo may show your connected usb devices):

enter image description here

I'm able to select the (any) device. But unable to call device.open().

document.getElementById("print-button-usb").addEventListener("click", () => {
  console.log('clicked');
  navigator.usb.requestDevice({ filters: [] })
    .then(device => {
      console.log('device paired', device);
      console.log(device.vendorId, typeof device.vendorId);
      return device;
    })
    .then(device => device.open()) // Error here <<-------------------------------------!
    .catch(err => console.error("my err", err));
})

enter image description here

Not only that printer, but I'm unable to open any connected shown devices. Can someone point out what am I missing here?

Environment details:

I've been following this guide: https://web.dev/usb


Update : (Debug informations) My chrome://device-log says: Failed to open /dev/bus/usb/001/005: Permission denied (13). I tried to cat that node:

$ cat /dev/bus/usb/001/005                    
@V       �2     �@@%                 
$ pwd
/dev/bus/usb/001
$ ls -l
total 0
crw-rw-r-- 1 root root 189, 0 Nov 30 23:13 001
crw-rw-r-- 1 root root 189, 1 Nov 30 23:13 002
crw-rw-r-- 1 root root 189, 2 Nov 30 23:13 003
crw-rw-r-- 1 root root 189, 3 Nov 30 23:13 004
crw-rw-r-- 1 root lp   189, 4 Dec  1 00:07 005


In the above image,


I tried to connect my phone over usb and tried to pair - I was able to pair it.

enter image description here

In this list, the "Pixel 3" device was the only device I was able to successfully connect. All others are returning the "Access Denied" error.

Upvotes: 2

Views: 5577

Answers (1)

mohammad farhady
mohammad farhady

Reputation: 53

Same problem here using FTDI device. I was able to get the device but not I could not open it with exactly the same error. I was using windows 10 by the way. Problem was solved by changing the driver from FTDI custom driver to WinUsb using zadig.

note: after doing so, the device could not be used by the previous .NET application and it is only accessible by the browser.

Upvotes: 1

Related Questions