Description
There are several files on sftp and the file size varies from 100MB to 2GB. The following code worked on 95% of the files. In most cases, it's an issue downloading large files (>500MB). In some cases, its trouble downloading the same file which succeed in the past. I tried to adjust the window size and packet size but I couldn't make it work for all files. I m looking for a consistent code that works for all files. I followed instructions from here https://stackoverflow.com/questions/45891553/paramiko-hangs-on-get-after-ownloading-20-mb-of-file/48170689#48170689. Am I missing anything here? Any inputs greatly appreciated.
Code
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.load_system_host_keys()
client.connect(connection['host'], username=connection['login'], password=connection['password'])
tr = client.get_transport()
tr.default_max_packet_size= 200 * 1024 * 1024
tr.default_window_size= paramiko.common.MAX_WINDOW_SIZE // 3
tr.packetizer.REKEY_BYTES = pow(2, 40)
tr.packetizer.REKEY_PACKETS = pow(2, 40)
sftp = client.open_sftp()
remote_sftp_file, local_sftp_file = '/users/xxx/1.txt', './test.txt'
sftp.get(remote_sftp_file,local_sftp_file)
Error
[2020-01-03 17:26:53,651] {logging_mixin.py:112} INFO - [2020-01-03 17:26:53,651] {transport.py:1819} ERROR - Socket exception: Connection reset by peer (104)
[2020-01-03 17:26:56,233] {logging_mixin.py:112} WARNING - Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/airflow/.local/lib/python3.6/site-packages/paramiko/sftp_file.py", line 538, in _prefetch_thread
self, CMD_READ, self.handle, long(offset), int(length)
File "/usr/local/airflow/.local/lib/python3.6/site-packages/paramiko/sftp_client.py", line 837, in _async_request
self._send_packet(t, msg)
File "/usr/local/airflow/.local/lib/python3.6/site-packages/paramiko/sftp.py", line 198, in _send_packet
self._write_all(out)
File "/usr/local/airflow/.local/lib/python3.6/site-packages/paramiko/sftp.py", line 162, in _write_all
n = self.sock.send(out)
File "/usr/local/airflow/.local/lib/python3.6/site-packages/paramiko/channel.py", line 801, in send
return self._send(s, m)
File "/usr/local/airflow/.local/lib/python3.6/site-packages/paramiko/channel.py", line 1208, in _send
self.transport._send_user_message(m)
File "/usr/local/airflow/.local/lib/python3.6/site-packages/paramiko/transport.py", line 1863, in _send_user_message
self._send_message(data)
File "/usr/local/airflow/.local/lib/python3.6/site-packages/paramiko/transport.py", line 1839, in _send_message
self.packetizer.send_message(data)
File "/usr/local/airflow/.local/lib/python3.6/site-packages/paramiko/packet.py", line 431, in send_message
self.write_all(out)
File "/usr/local/airflow/.local/lib/python3.6/site-packages/paramiko/packet.py", line 367, in write_all
raise EOFError()
EOFError
Activity
kkr78 commentedon Jan 6, 2020
Let me know if you guys want me to enable debug and capture logs
egh commentedon Jul 13, 2020
https://stackoverflow.com/a/58339631
rickodell commentedon May 25, 2022
https://gist.github.com/vznncv/cb454c21d901438cc228916fbe6f070f