-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
netmiko.ssh_exception.NetMikoTimeoutException #1151
Comments
Are you changing the hostname by any chance? Also can you enable logging and post that here, see this link: https://github.com/ktbyers/netmiko/blob/develop/COMMON_ISSUES.md#enable-netmiko-logging-of-all-reads-and-writes-of-the-communications-channel |
Im running python on a network automation machine inside GNS3. debug = True def read_until_pattern(self, *args, **kwargs): I run again de script to configure equipment and : Preparing to config During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): Run the script on a second try and it goes fine! |
@nonioAtoz Try setting iosv_l2 = {
'device_type': 'cisco_ios',
'ip' : '192.168.134.81',
'username' : 'nuno',
'password' : 'cisco',
'global_delay_factor': 4,
} Does that help? |
It did nt work , but i ithink i have found the problem ( im also new to network devices and protocols and make a lot of mistakes): |
@nonioAtoz Okay, so I am assuming that means that your change was disconnecting the Linux automation server where Netmiko was running--thus causing the connection to break? |
i was perfoming this commands on switch and this ports were configured and the the connection breaks . I also run the same problem when reseting switch configuration to defaults . |
I HAVE A SIMPLE SCRIPT USING NETMIKO MODULE, THAT FROM A FILE WITH CONFIGS, TRY TO CONFIGURE A CISCO SWITCH. THE PROBLEM IS THAT IT ONLY WORKS SOMETIMES IN A RANDOM WAY, LIKE I RUN THE SCRIPT ONE TIME , IT RAISES THIS ERROR, THEN I RUN AGAIN AND IT WILL CONFIGURE THE SWITCH. i ALSO DID A GOOGLE SEARCH AND THE BEST I COULD FIND WAS THIS : #212
the ERROR : File "/usr/local/lib/python3.5/dist-packages/paramiko/channel.py", line 699, in recv
out = self.in_buffer.read(nbytes, self.timeout)
File "/usr/local/lib/python3.5/dist-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.5/dist-packages/netmiko/base_connection.py", line 519, in _read_channel_expect
new_data = self.remote_conn.recv(MAX_BUFFER)
File "/usr/local/lib/python3.5/dist-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 "compara_Configura.py", line 73, in
output = net_connect.send_config_from_file(ficheiro)
File "/usr/local/lib/python3.5/dist-packages/netmiko/base_connection.py", line 1502, in send_config_from_file
return self.send_config_set(cfg_file, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/netmiko/base_connection.py", line 1567, in send_config_set
output += self.exit_config_mode()
File "/usr/local/lib/python3.5/dist-packages/netmiko/cisco_base_connection.py", line 56, in exit_config_mode
exit_config=exit_config, pattern=pattern
File "/usr/local/lib/python3.5/dist-packages/netmiko/base_connection.py", line 1478, in exit_config_mode
if self.check_config_mode():
File "/usr/local/lib/python3.5/dist-packages/netmiko/cisco/cisco_ios.py", line 32, in check_config_mode
check_string=check_string, pattern=pattern
File "/usr/local/lib/python3.5/dist-packages/netmiko/cisco_base_connection.py", line 38, in check_config_mode
check_string=check_string, pattern=pattern
File "/usr/local/lib/python3.5/dist-packages/netmiko/base_connection.py", line 1448, in check_config_mode
output = self.read_until_pattern(pattern=pattern)
File "/usr/local/lib/python3.5/dist-packages/netmiko/base_connection.py", line 594, in read_until_pattern
return self._read_channel_expect(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/netmiko/base_connection.py", line 528, in _read_channel_expect
"Timed-out reading channel, data not available."
netmiko.ssh_exception.NetMikoTimeoutException: Timed-out reading channel, data not available.
the sCRIPT :
!/usr/bin/env python3
-- encoding: utf-8 --
"""
This script read the running config from a network device , and read previous known running config
from a file , and it compares it . if both are equal it does not do nothing .
if they are diferents try to configure the switch
"""
from netmiko import ConnectHandler
from netmiko.ssh_exception import NetMikoTimeoutException
from paramiko.ssh_exception import SSHException
from netmiko.ssh_exception import AuthenticationException
from show_run import show_run
iosv_l2 = {
'device_type': 'cisco_ios',
'ip' : '192.168.134.81',
'username' : 'nuno',
'password' : 'cisco'
'blocking_timeout':16,
'timeout': 60,
'session_timeout':60
}
Call fucntion to get running config of cisco network device and store in
a list " device_running_config"
device_running_config = show_run(iosv_l2)
for line in device_running_config:
line.splitlines()
print( device_running_config)
open a configuration file from the equipment that we know that is correct
ficheiro = open("backup_s1","r")
linhas = ficheiro.read().splitlines()
ficheiro.close()
print("################################################################")
print(linhas)
print("################################################################")
Compare 2 running configs - if they are equal do nothing . if they are
diferent config the network device from a file
file with the configuration commands of the network device
ficheiro = 's1_config'
if linhas == device_running_config:
else:
print( "###########################################################")
print ("they are diferent \n Preparing to config")
print ("############################################################")
try:
net_connect = ConnectHandler(**iosv_l2)
except (AuthenticationException):
print ('Authentication failure: ' + ip_address_of_device)
output = net_connect.send_config_from_file(ficheiro)
print (output)
Thanks you all !
The text was updated successfully, but these errors were encountered: