Skip to content

HID Device Open Failure & Retry #8

@rudyrichter

Description

@rudyrichter

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions