Skip to content

Commit

Permalink
Adds a timeout to the SSH channel. (#45)
Browse files Browse the repository at this point in the history
This resolves an issue in which a channel.recv() operation can hang when
the host's sshd is alive but netconfd has hung or fallen over.  The TCP
socket and Paramiko Transport do not time out because data is still
flowing, but the NETCONF connection hangs.  We have observed a simple
NETCONF HELLO exchange to hang for over 2.5 hours in the wild despite
the socket timeout being set.

Paramiko channels, it turns out, have their own timeout that is
independdent of the socket/transport timeout.
  • Loading branch information
APCBoston authored Oct 31, 2024
1 parent 73eea8b commit 892153b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion netconf_client/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def connect_ssh(
hostkey = _try_load_hostkey_b64(hostkey_b64) if hostkey_b64 else None
transport.connect(username=username, password=password, pkey=pkey)
try:
channel = transport.open_session()
channel = transport.open_session(timeout=general_timeout)
except Exception:
transport.close()
raise
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "netconf_client"
version = "3.1.1"
version = "3.1.2"
description = "A Python NETCONF client"
authors = ["ADTRAN, Inc."]
license = "Apache-2.0"
Expand Down

0 comments on commit 892153b

Please # to comment.