Timeout for Device.open()
See original GitHub issueI have been going through the code and scratching my head as to how to get Device
to timeout in a reasonable amount of time when I first call open()
. The specific scenario is to have netconf enabled on the device via ssh but the protect RE firewall filter does not allow netconf access. On such a device it takes upwards or 2 minutes to timeout the connection on open()
which gets extremely annoying when I am trying to connect to many devices.
I would like to have the ability to pass a timeout value to open()
to quickly throw an error on a connection that will never open in the first place.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Troubleshoot Junos PyEZ Errors When Configuring Junos ...
Problem. Description. The Junos PyEZ code generates an RpcTimeoutError message or a TimeoutExpiredError message and fails to update the device configuration.
Read more >What Does a Server Connection Timeout Mean?
A server connection timeout means that a server is taking too long to reply to a data request made from another device. Timeouts...
Read more >open() timeout - Phidgets.com
Re: open() timeout ... That make sense. I've landed on calling openWaitForAttachment() initially then in the exception handler when it timesout ...
Read more >The device, \Device\Ide\iaStor0, did not respond ... - TechNet
... \Device\Ide\iaStor0, did not respond within the timeout period. ... Left click "Port0" to open and in the pane with Name/Type/Data, ...
Read more >6.10. timeout
A following read() can take as long as the user likes. Timeouts are best avoided, especially if SCSI bus resets will adversely effect...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
TL;DR: it should be possible to set ssh connect timeout via the “connecttimeout” parameter in ~/.ssh/config (or some other ssh config file with custom path). I did some debugging and looks like:
and re-run my debugging. The value 42 was read and applied in https://github.com/ncclient/ncclient/blob/v0.6.6/ncclient/transport/ssh.py#L403 BTW the ssh_config man page (see on your computer or e.g. at https://linux.die.net/man/5/ssh_config) says that the keywords are case-insensitive and indeed it is parsed like that (ncclient uses the config parsing of paramiko (ssh client library) which converts the keywords to lowercase).
Update: to test this I created a “black hole” IP address such that all packets sent to it from my computer will be dropped:
I verified that the command line ssh client now times out in 42s using this IP:
So far so good. I also verified that socket connect at https://github.com/ncclient/ncclient/blob/v0.6.6/ncclient/transport/ssh.py#L409 timed out in 42s and there was some timeout exception raised. When not using the “connecttimeout” in ~/.ssh/config then I got the jnpr.junos.exception.ConnectTimeoutError in about 96-99 sec (but in your system it might be different).
Update2: at one occasion I saw the timeout happening in about 11 sec (if I am not mistaken). (then again 42 without any code change) Could be a python (3.7.4) or Linux kernel (5.1.21) issue??? But usually it works correctly, so maybe it was an exceptional case.
what is current timeout value of the open()? is there any plan to fix this issue, am hitting this one on my network. I need to increase the timeout value.