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
NX-OS device terminating connection in check_config_mode #1759
Comments
@lazhao123 I probably need the Netmiko log file for more information: |
[test.log](https://github.com/ktbyers/netmiko/files/4685200/test.log)
Hi Kirk,
Thank you for looking into this. Log attached.
…On Tue, May 26, 2020 at 12:53 PM Kirk Byers ***@***.***> wrote:
@lazhao123 <https://github.com/lazhao123> I probably need the Netmiko log
file for more information:
https://github.com/ktbyers/netmiko/blob/develop/COMMON_ISSUES.md#enable-netmiko-logging-of-all-reads-and-writes-of-the-communications-channel
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1759 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHHRWLYBGUMXFXL6ZLO6KHTRTQM5FANCNFSM4NK4T5KA>
.
|
@lazhao123 I don't see any log-file? |
I email comments with attaching log, but it didn't attached. Now I attached. |
re-attach the log in case you did not get. |
Hi Kirk, Do you need more info on this issue? Thanks in advance for any advice |
What happens with |
When cmd_verify set to True, it cause "prompt not found" error. So I don't
verify the prompt after sending config.
In my case, how to keep connection open until I sent all commands? I
thought keep_alive is used for this purpose.
Does the log file gives any hint?
…On Wed, May 27, 2020 at 4:00 PM Kirk Byers ***@***.***> wrote:
What happens with cmd_verify=True?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1759 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHHRWL474AQGQO66P7QDSW3RTWLR7ANCNFSM4NK4T5KA>
.
|
Sorry to keep asking advice. |
I need the full exception stack trace and Netmiko-log for cmd_verify=True. I think you are in a context when you probably require cmd_verify (i.e. very large number of configuration commands where you are going to run into input buffer issues without cmd_verify). That being said, I didn't really anything all that useful in the log file. Regards, Kirk |
============ stack trace: 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): ============ The source code is: ============ The CLI commands are: ============ Netmiko-log file attached. |
Really no clues at the end of the log...the end of the log looks odd from a Netmiko perspective (i.e. there is nothing there or significance): The log file doesn't match your code (are you just appending to the end of a log file that has other things in it)? How many total lines of configuration changes are you trying to make? |
Hi Kirk, Thank you for the help. |
Have you tried |
EOFError: Channel stream closed by remote device. ============= The code is: |
Is there any intermediate firewall that might be terminating the connection? Are there any log messages on the network device indicating it is closing the connection? |
The switch and windows server are connected in same rack with direct connection. There is no firewall in between. Device configuration are mostly default. dump-cap.log is packet capture on device mgmt port, please rename it and open in wireshark. console log also attached. |
Okay, I am a bit at a loss here...the evidence indicates the network device is closing the connection. Have you tried setting the VTY timeout to a large value? I guess another option is to use a NAPALM-style file merge for your large configuration set (that uses Netmiko under the hood). |
The default nexus inactive vty timeout is 30 minutes. That's enough time to complete the operation. My script is sending a few commands at a time and driven by user. So I can't use NAPALM. Script works fine except this issue. It happens when I send many config commands to device. Google for "Socket exception: An existing connection was forcibly closed by the remote host (10054)" returns many links for this issue. I use "net_connect.disconnect()" to disconnect session after script complete sending config. Is Netmiko gracefully close the session? I also tried keep_alive=10, still the same. |
How about trying to increase the blocking_timeout to 40? This is an argument to ConnectHandler? I am going to keep circling back to the network device or something in between is closing the connection for some reason (as that is what the data/log messages indicate). So does it work reliably for smaller configuration changes? Is there any packet loss between you and the network device (i.e. are there reliability issues on the connection)? |
Added blocking_timeout=40 to ConnectHandler. Still get exception. The server to switch is direct connect, switch is basic configuration and new. It is the only server to the switch. Is it possible to add timestamp on Netmiko log? I modified init.py, but two streams are output to console so the console has duplicate output. By watching the console, I noticed script stops 3 times and finally close stream by remote. 2020-06-05 21:00:48,192: Pattern is: (?:R1-93180YC-EX-A|#) The script runs from: 2020-06-05 20:58:21,567: read_channel: When script send few commands, then wait sometime, send again. It is fine. |
Can you post the exact code you are using to test with (failing case). You can obfuscate any passwords/confidential information. |
To reproduce it, I send config in loop. interface is from 1/1 to 1/54. commands = ['interface Ethernet1/1', |
Hi Kirk, Have you reproduced it? TIA |
I haven't got to this... |
Okay, I did this test, configuring roughly 50 interfaces repeated five times on one of my NX-OS switches and didn't see an issue. |
Cool, can I test the fix? |
There is no fix...I didn't see any issue. I was just using the |
i.e. I couldn't reproduce the problem. |
But you might want to test with the |
I have narrowed down the issue. here is the port status, it is default configuration. Ethernet VLAN Type Mode Status Reason Speed Port Here is the code: def run_debug_config(config_commands): config_commands=['int Ethernet1/41', 'no switchport', 'switchport'] Socket exception: An existing connection was forcibly closed by the remote host (10054) |
Why are you toggling "switchport -> no switchport"? What model Nexus is this? Kirk |
I use "no switchport", "switchport" to reset the port. "default" command has same issue. |
Hi Kirk, |
What happens if you try this? net_connect = ConnectHandler(
device_type='cisco_nxos_ssh',
ip=xxx,
username=xxx,
password=xxx,
global_delay_factor=4,
blocking_timeout=40
) |
Tried, still same error. Thank you for helping me on this. |
Are you able to reproduce the issue? |
No, I couldn't reproduce it. It looks like an NX-OS issue and not a Netmiko issue. I would probably work-around it by transferring the config file via Secure Copy and then copying the changes into running-config (but I know you said that wouldn't work for you). |
I will try it on arista switch sometime and post update. |
arista switch doesn't have issue. So I need to change my code. |
I am going to close this issue as I don't think it is a Netmiko issue. My solution to the problem would be to use a file merge operation similar to what is done in NAPALM using the nxos_ssh operation. I know you said that solution would not work for you (earlier), but that is how I would likely work around the problem. You would have to put in some error handling in your code to find where the error happened. This might require you to write your own custom method using write_channel and read_channel. We do have this PR here which might help, but we haven't completed it: Regards, Kirk |
Hello,
I got connection closed exception when I send many interface commands to cisco nexus device.
On CLI, device can handle this many commands, but on script, it gives exception.
If I give keep_alive, why connection still be closed by remote?
Socket exception: An existing connection was forcibly closed by the remote host (10054)
Traceback (most recent call last):
File "d:.......\Python\Python37\lib\site-packages\netmiko\base_connection.py", line 1739, in send_config_set
output += self.exit_config_mode()
File "d:.......\Python\Python37\lib\site-packages\netmiko\cisco_base_connection.py", line 44, in exit_config_mode
return super().exit_config_mode(exit_config=exit_config, pattern=pattern)
File "d:.......\Python\Python37\lib\site-packages\netmiko\base_connection.py", line 1615, in exit_config_mode
if self.check_config_mode():
File "d:.......\Python\Python37\lib\site-packages\netmiko\cisco\cisco_nxos_ssh.py", line 27, in check_config_mode
return super().check_config_mode(check_string=check_string, pattern=pattern)
File "d:.......\Python\Python37\lib\site-packages\netmiko\cisco_base_connection.py", line 30, in check_config_mode
return super().check_config_mode(check_string=check_string, pattern=pattern)
File "d:.......\Python\Python37\lib\site-packages\netmiko\base_connection.py", line 1582, in check_config_mode
output = self.read_until_pattern(pattern=pattern)
File "d:.......\Python\Python37\lib\site-packages\netmiko\base_connection.py", line 618, in read_until_pattern
return self._read_channel_expect(*args, **kwargs)
File "d:.......\Python\Python37\lib\site-packages\netmiko\base_connection.py", line 543, in _read_channel_expect
raise EOFError("Channel stream closed by remote device.")
EOFError: Channel stream closed by remote device.
['interface Ethernet1/1',
'no switchport',
'no description',
'no speed auto',
... omit ...
'interface Ethernet1/60',
'no switchport',
'no description',
'no speed auto']
net = ConnectHandler(device_type=self.deviceType, ip=self.host, username=self.username,
password=self.password, global_delay_factor=3, keepalive=10)
output = net.send_config_set(commands, cmd_verify=False)
The text was updated successfully, but these errors were encountered: