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

HID Device Open Failure & Retry #8

Open
rudyrichter opened this issue May 23, 2019 · 0 comments
Open

HID Device Open Failure & Retry #8

rudyrichter opened this issue May 23, 2019 · 0 comments

Comments

@rudyrichter
Copy link

description:
We're seeing a behavior with some yubikey devices where the initial attempt to open the device will fail due to a read timeout. This is typically when the device has sat connected and idle for a bit, but not always.

sample code:

	devices, err := u2fhid.Devices()
	if err != nil {
		return nil, err
	}
	if len(devices) == 0 {
		return nil, errors.New("No keys found")
	}

	d := devices[0]

	dev, err := u2fhid.Open(d)
	if err != nil {
		return nil, err
	}
	t := u2ftoken.NewToken(dev)

result:
u2fhid: error reading response, read timed out is logged to console.

If we immediately attempt to open the connection again after it initially fails, it succeeds in opening and we can proceed to generate a NewToken(dev) and go about doing what we need to do.

	dev, err := u2fhid.Open(d)
	if err != nil {
		fmt.Println("Failed to open, trying again.")
		dev, err = u2fhid.Open(d)
		if err != nil {
			return nil, err
		}
	}

We're not sure if there is a timing issue where the device is taking longer to stand up for the HIDManager than expected so when it attempts to write to the device and read from the device in hid.go's device init function that the device is not yet ready to talk to the client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant