Python script times out during IOS download

[ Edited ]
Posts: 2
132     0



I have a Python script to download IOS file to switches but as TFTP server is not local it can take about 10 minutes to download. I have set Script-Timeout to 1800 and thought this would help but it makes no difference and script fails after 5 minutes while download is still in progress.


Script section to download the file:

if check_file_present (tftp_file_name) == 0:
easy.log_message("info", "Switch image file {} - upload starts".format(tftp_file_name))
easy.send_command("copy tftp://{srv}{path}{file} flash:\r\r".format(


Error message I can see in Process Log after 5 minutes:


*** Error / Traceback (most recent call last): 
   File "", line 196, in  
   File "/mnt/host/lib/", line 88, in send_command 
   File "/usr/lib/python3.4/site-packages/infoblox_netmri/api/broker/v3_3_0/", line 221, in send_command 
     return self.api_request(self._get_method_fullname("send_command"), kwargs) 
   File "/usr/lib/python3.4/site-packages/infoblox_netmri/api/broker/", line 24, in api_request 
   File "/usr/lib/python3.4/site-packages/infoblox_netmri/", line 227, in api_request 
     return self._make_request(url=url, method="post", data=data) 
   File "/usr/lib/python3.4/site-packages/infoblox_netmri/", line 103, in _make_request 
     return self._send_request(url, method, data, extra_headers) 
   File "/usr/lib/python3.4/site-packages/infoblox_netmri/", line 129, in _send_request 
     raise HTTPError(res.json(), response=res) 
 requests.exceptions.HTTPError: {'error': 'general/cli-error', 'message': 'Device command timeout or connection lost.'} 

LPNLROT20S313#show flash: | include c2960-lanbasek9-mz.122-55.SE12.bin 
 LPNLROT20S313#copy t flash: 
 Destination filename [c2960-lanbasek9-mz.122-55.SE12.bin]?  
 Accessing t 
 Loading Cisco/2960/c2960-lanbasek9-mz.122-55.SE12.bin from (via Vlan300): !!!!!!!!!!!!!!!!!! 


Any suggestions how to fix that? I've even set exec-timeout under VTY session on the switch for 30 minutes but still makes no difference.



Re: Python script times out during IOS download

Posts: 251
133     0

I don't have an answer to your direct question -- hopefully Sif does.


But FWIW, you can probably speed up the file transfers by switching to a TCP-based method -- HTTP(S), FTP, SCP, etc.  On the IOS devices, improve the throughput by addding:

  ip tcp mss 1460   !Lower if VPN or other encapsulation overhead

  ip tcp selective-ack

  ip tcp windows 65536


Also, "ip ssh timeout" is not a keep-alive.  It only limits how long a device that is initiating a connection will wait for the SSH session to become established.


And lastly, IOS 12.2(55)SE12 is really old and has a list of vulnerabilities according to the SotwareChecker.  Fixes are in 12.2(55)SE13 which is not yet available to download.  But a better choice would be 15.0(2)SE12 which we still run in over 80 (EOL) 2960 switches.

Re: Python script times out during IOS download

[ Edited ]
Posts: 2
133     0



Yes, our switches are really old and this is just keeping them more secure till they are replaced. According to CISCO website IOS 12.2(55)SE12 is the recommended MD firmware and I can't see any bugs for our switch model.

Also, I am a bit worried to go to version 15 as not sure how much has the syntax and commands changed and we don't have a spare switch to test it on. 


Also, when tried ftp as transfer method it doesn't even ask me for username and password (probably not supported in the current IOS) and I can't create anonymous account on the server. 


That SSH timeout is actually an exex-timeout under VTY session (my bad for wrong facts) so this should keep session alive for 30 minutes, shouldn't it?

Showing results for 
Search instead for 
Do you mean 

Recommended for You