我使用SSHChannel通过“持久性”SSHConnection。偶尔,以前关闭的localChannel将尝试使用并导致KeyError,因为localChannel不在SSHConnection.channels []中。twisted(17.5.0)SSHConnection使用先前关闭的通道(ssh_CHANNEL_OPEN_CONFIRMATION)
下面是一些日志片段:
2017-07-05 07:54:50-0500 [-] openChannel localChannelID=2
2017-07-05 07:54:50-0500 [-] opening channel 2 with 65536 32768
2017-07-05 07:54:50-0500 [SSHChannel session (2) on SSHService 'ssh-connection' on ClientTransport,client] sending close 2
2017-07-05 07:54:50-0500 [SSHService 'ssh-connection' on ClientTransport,client] channelClosed id=2
所以,现在通道2被关闭。后来(经过几次新的渠道),我看到:
2017-07-05 08:54:55-0500 [-] openChannel localChannelID=2
2017-07-05 08:54:55-0500 [-] opening channel 2 with 65536 32768
2017-07-05 08:54:55-0500 [SSHService 'ssh-connection' on ClientTransport,client] Unhandled Error Traceback (most recent call last):
<snipped irrelevant>
File "/usr/local/lib/python2.7/dist-packages/twisted/conch/ssh/connection.py", line 180, in ssh_CHANNEL_OPEN_CONFIRMATION channel = self.channels[localChannel]
exceptions.KeyError: 2
请注意,我对连接定时器,但我在使用之前重置这些。
我迷路了,无法确定它为什么“大部分时间”工作,但随后失败。我如何测试以防止因为它似乎打开没有任何明显的错误。