paramiko 遭遇socket.error: Socket is closed 错误的解决办法
Posted Vooom
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了paramiko 遭遇socket.error: Socket is closed 错误的解决办法相关的知识,希望对你有一定的参考价值。
似乎是connection自己断了解决的办法是在创建conn的时候添加下面这句
conn.keep_this = conn_session
完整代码
def create_a_conn(ip_addr, port, username, password):
\'\'\'
creat a conn to router using paramiko.SSHClient()
\'\'\'
conn_session = paramiko.SSHClient()
conn_session.load_system_host_keys()
conn_session.connect(ip_addr, port, username, password, look_for_keys = False, allow_agent = False)
conn = conn_session.invoke_shell()# to keep the session go on
conn.keep_this = conn_session
time.sleep(1)
conn.send("terminal length 0\\n")
time.sleep(1)
if conn.recv_ready():
conn.recv(65535)
return conn
以上是关于paramiko 遭遇socket.error: Socket is closed 错误的解决办法的主要内容,如果未能解决你的问题,请参考以下文章
Asynchronous socket error 10053