Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paramiko Timeout issue #73

Open
WindfuryARS opened this issue Jul 3, 2021 · 1 comment
Open

Paramiko Timeout issue #73

WindfuryARS opened this issue Jul 3, 2021 · 1 comment

Comments

@WindfuryARS
Copy link

I got a problem regarding "paramiko.buffered_pipe.PipeTimeout". My script could have expected output while I'm executing it on my MAC

from netmiko import ConnectHandler
from datetime import datetime
import time
import getpass


def getPTPstate(username,pw):
    cisco = {
        'device_type': 'cisco_nxos',
        'host': "10.122.164.139",
        'username': username,
        'password': pw
    }
    all_device = [cisco]
    
    for i in all_device:
        net_connect = ConnectHandler(**i)
        output1 = net_connect.send_command("show ptp clock | in Identity | awk  '{print $4}'").strip("\n")
        output2 = net_connect.send_command('show switchname').replace(" ","").strip()
        print(output2 + "'s PTP GM is " + output1)


getPTPstate("admin","cisco!123")

$ python3 /Users/hancai/Desktop/ptplogin.py
F340.09.16-93180YC-FX-CD1_N93-1's PTP GM is 00:de:fb:ff:fe:fa:47:87

Somehow, it would return incorrect output if I was running same script in another server. I suppose there is performance issue in server, do we have any way to extend Timeout value?

$ python3 ptplogin.py
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/paramiko/channel.py", line 699, in recv
out = self.in_buffer.read(nbytes, self.timeout)
File "/usr/local/lib/python3.7/site-packages/paramiko/buffered_pipe.py", line 164, in read
raise PipeTimeout()
paramiko.buffered_pipe.PipeTimeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/netmiko/base_connection.py", line 541, in _read_channel_expect
new_data = self.remote_conn.recv(MAX_BUFFER)
File "/usr/local/lib/python3.7/site-packages/paramiko/channel.py", line 701, in recv
raise socket.timeout()
socket.timeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "ptplogin.py", line 24, in
getPTPstate("admin","cisco!123")
File "ptplogin.py", line 19, in getPTPstate
output1 = net_connect.send_command("show ptp clock | in Identity | awk '{print $4}'").strip("\n")
File "/usr/local/lib/python3.7/site-packages/netmiko/base_connection.py", line 1366, in send_command
new_data = self.read_until_pattern(pattern=re.escape(cmd))
File "/usr/local/lib/python3.7/site-packages/netmiko/base_connection.py", line 618, in read_until_pattern
return self._read_channel_expect(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/netmiko/base_connection.py", line 552, in _read_channel_expect
"Timed-out reading channel, data not available."
netmiko.ssh_exception.NetmikoTimeoutException: Timed-out reading channel, data not available.

``

``

@fruch
Copy link
Collaborator

fruch commented Oct 2, 2022

What's netmiko ? this code is only tested with paramiko...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants