question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Timeout with send_config_set

See original GitHub issue

Hi

I’m starting to learn Netmiko and have, very early on, encountered a time out problem when using send_config_set.

When using the send_command method to send a Show command on a Cisco switch, it returns the info as expected, but when sending config commands with send_config_set, I get a timeout.

Script:

from netmiko import ConnectHandler

switch1 = {
    'device_type': 'cisco_ios',
    'ip': '172.16.233.10',
    'username': 'user',
    'password': 'cisco'
}

net_connect = ConnectHandler(**switch1)
output = net_connect.send_command('sh ip int br')
print(output)

config_commands = ['int loop 0', 'ip address 10.1.1.1 255.255.255.0']
output = net_connect.send_config_set(config_commands)
print(output)

Output:

/Users/User/.conda/envs/default/bin/python /Users/User/Documents/PycharmProjects/Network_Automation/Netmiko/netmiko1.py
Interface              IP-Address      OK? Method Status                Protocol
GigabitEthernet0/0     unassigned      YES unset  up                    up      
GigabitEthernet0/1     unassigned      YES unset  up                    up      
GigabitEthernet0/2     unassigned      YES unset  up                    up      
Vlan1                  172.16.233.10   YES NVRAM  up                    up      
Traceback (most recent call last):
  File "/Users/User/.conda/envs/default/lib/python3.7/site-packages/paramiko/channel.py", line 699, in recv
    out = self.in_buffer.read(nbytes, self.timeout)
  File "/Users/User/.conda/envs/default/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 "/Users/User/.conda/envs/default/lib/python3.7/site-packages/netmiko/base_connection.py", line 519, in _read_channel_expect
    new_data = self.remote_conn.recv(MAX_BUFFER)
  File "/Users/User/.conda/envs/default/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 "/Users/User/Documents/PycharmProjects/Network_Automation/Netmiko/netmiko1.py", line 15, in <module>
    output = net_connect.send_config_set(config_commands)
  File "/Users/User/.conda/envs/default/lib/python3.7/site-packages/netmiko/base_connection.py", line 1554, in send_config_set
    output = self.config_mode(*cfg_mode_args)
  File "/Users/User/.conda/envs/default/lib/python3.7/site-packages/netmiko/cisco_base_connection.py", line 50, in config_mode
    config_command=config_command, pattern=pattern
  File "/Users/User/.conda/envs/default/lib/python3.7/site-packages/netmiko/base_connection.py", line 1461, in config_mode
    if not self.check_config_mode():
  File "/Users/User/.conda/envs/default/lib/python3.7/site-packages/netmiko/cisco/cisco_ios.py", line 32, in check_config_mode
    check_string=check_string, pattern=pattern
  File "/Users/User/.conda/envs/default/lib/python3.7/site-packages/netmiko/cisco_base_connection.py", line 38, in check_config_mode
    check_string=check_string, pattern=pattern
  File "/Users/User/.conda/envs/default/lib/python3.7/site-packages/netmiko/base_connection.py", line 1448, in check_config_mode
    output = self.read_until_pattern(pattern=pattern)
  File "/Users/User/.conda/envs/default/lib/python3.7/site-packages/netmiko/base_connection.py", line 594, in read_until_pattern
    return self._read_channel_expect(*args, **kwargs)
  File "/Users/User/.conda/envs/default/lib/python3.7/site-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.

Process finished with exit code 1

I’ve connected to the same switch using the Python’s telnetlib module and it connects fine so the issue appears to be something with paramiko/netmiko using SSH.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
torooDamaencommented, Jan 24, 2020

Hi

I’m starting to learn Netmiko and have, very early on, encountered a time out problem when using send_config_set.

When using the send_command method to send a Show command on a Cisco switch, it returns the info as expected, but when sending config commands with send_config_set, I get a timeout.

Script:

from netmiko import ConnectHandler

switch1 = {
    'device_type': 'cisco_ios',
    'ip': '172.16.233.10',
    'username': 'user',
    'password': 'cisco'
}

net_connect = ConnectHandler(**switch1)
output = net_connect.send_command('sh ip int br')
print(output)

config_commands = ['int loop 0', 'ip address 10.1.1.1 255.255.255.0']
output = net_connect.send_config_set(config_commands)
print(output)

Output:

/Users/User/.conda/envs/default/bin/python /Users/User/Documents/PycharmProjects/Network_Automation/Netmiko/netmiko1.py
Interface              IP-Address      OK? Method Status                Protocol
GigabitEthernet0/0     unassigned      YES unset  up                    up      
GigabitEthernet0/1     unassigned      YES unset  up                    up      
GigabitEthernet0/2     unassigned      YES unset  up                    up      
Vlan1                  172.16.233.10   YES NVRAM  up                    up      
Traceback (most recent call last):
  File "/Users/User/.conda/envs/default/lib/python3.7/site-packages/paramiko/channel.py", line 699, in recv
    out = self.in_buffer.read(nbytes, self.timeout)
  File "/Users/User/.conda/envs/default/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 "/Users/User/.conda/envs/default/lib/python3.7/site-packages/netmiko/base_connection.py", line 519, in _read_channel_expect
    new_data = self.remote_conn.recv(MAX_BUFFER)
  File "/Users/User/.conda/envs/default/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 "/Users/User/Documents/PycharmProjects/Network_Automation/Netmiko/netmiko1.py", line 15, in <module>
    output = net_connect.send_config_set(config_commands)
  File "/Users/User/.conda/envs/default/lib/python3.7/site-packages/netmiko/base_connection.py", line 1554, in send_config_set
    output = self.config_mode(*cfg_mode_args)
  File "/Users/User/.conda/envs/default/lib/python3.7/site-packages/netmiko/cisco_base_connection.py", line 50, in config_mode
    config_command=config_command, pattern=pattern
  File "/Users/User/.conda/envs/default/lib/python3.7/site-packages/netmiko/base_connection.py", line 1461, in config_mode
    if not self.check_config_mode():
  File "/Users/User/.conda/envs/default/lib/python3.7/site-packages/netmiko/cisco/cisco_ios.py", line 32, in check_config_mode
    check_string=check_string, pattern=pattern
  File "/Users/User/.conda/envs/default/lib/python3.7/site-packages/netmiko/cisco_base_connection.py", line 38, in check_config_mode
    check_string=check_string, pattern=pattern
  File "/Users/User/.conda/envs/default/lib/python3.7/site-packages/netmiko/base_connection.py", line 1448, in check_config_mode
    output = self.read_until_pattern(pattern=pattern)
  File "/Users/User/.conda/envs/default/lib/python3.7/site-packages/netmiko/base_connection.py", line 594, in read_until_pattern
    return self._read_channel_expect(*args, **kwargs)
  File "/Users/User/.conda/envs/default/lib/python3.7/site-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.

Process finished with exit code 1

I’ve connected to the same switch using the Python’s telnetlib module and it connects fine so the issue appears to be something with paramiko/netmiko using SSH.

Please kindly help me if u had a fix to this issue. i am currently facing the same problem. i need help

0reactions
robin113xcommented, Nov 20, 2020

use this command username privilege 15

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting timeout when generating RSA key in python script ...
I'm using send_config_set to send the config lines that start with "crypto generate key rsa modulus 2048". This command doesn't require any additional...
Read more >
netmiko API documentation - GitHub Pages
:param banner_timeout: Set a timeout to wait for the SSH banner (pass to Paramiko). ... :param kwargs: params to be sent to send_config_set...
Read more >
python 3.x - I keep geting this error related with Netmiko when ...
I keep geting this error related with Netmiko when sending send_config_set(), but send_comand() works? Ask Question. Asked 2 years, 7 months ago.
Read more >
netmiko_send_config — nornir-salt 0.12.0 documentation
This task plugin relies on Netmiko conection send_config_set method to send configuration commands to devices over SSH or Telnet.
Read more >
Netmiko4 read_timeout - Python for Network Engineers
What Netmiko users need is a simple timeout. In other words, wait x-amount of time and if the trailing prompt is not returned, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found