paramiko sftp服务器连接掉线了

时间:2013-02-21 19:22:43

标签: python-2.7 paramiko

我正在尝试使用paramiko sftp复制大文件(~650mb)文件。我能够复制小文件,但是当我尝试复制大文件时,我看到以下错误。我可以使用sftp直接从终端复制文件。

Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 504, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.7/dist-packages/paramiko/sftp_file.py", line 453, in _prefetch_thread
    self.sftp._async_request(self, CMD_READ, self.handle, long(offset), int(length))
  File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 656, in _async_request
    self._send_packet(t, str(msg))
  File "/usr/lib/python2.7/dist-packages/paramiko/sftp.py", line 172, in _send_packet
    self._write_all(out)
  File "/usr/lib/python2.7/dist-packages/paramiko/sftp.py", line 136, in _write_all
    n = self.sock.send(out)
  File "/usr/lib/python2.7/dist-packages/paramiko/channel.py", line 701, in send
    self.transport._send_user_message(m)
  File "/usr/lib/python2.7/dist-packages/paramiko/transport.py", line 1426, in _send_user_message
    self._send_message(data)
  File "/usr/lib/python2.7/dist-packages/paramiko/transport.py", line 1406, in _send_message
    self.packetizer.send_message(data)
  File "/usr/lib/python2.7/dist-packages/paramiko/packet.py", line 310, in send_message
    self.write_all(out)
  File "/usr/lib/python2.7/dist-packages/paramiko/packet.py", line 260, in write_all
    raise EOFError()
EOFError

Traceback (most recent call last):
  File "./extract.py", line 107, in <module>
    main()
  File "./extract.py", line 81, in main
    getFiles()
  File "./extract.py", line 58, in getFiles
    'ABC.zip')
  File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 614, in get
    data = fr.read(32768)
  File "/usr/lib/python2.7/dist-packages/paramiko/file.py", line 153, in read
    new_data = self._read(read_size)
  File "/usr/lib/python2.7/dist-packages/paramiko/sftp_file.py", line 152, in _read
    data = self._read_prefetch(size)
  File "/usr/lib/python2.7/dist-packages/paramiko/sftp_file.py", line 132, in _read_prefetch
    self.sftp._read_response()
  File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 668, in _read_response
    raise SSHException('Server connection dropped: %s' % (str(e),))
paramiko.SSHException: Server connection dropped: 

此操作仅在读取一定数量的字节后才会抛出。我在sftp_client.py中引入了一个print语句,这是输出(字节)

reading bytes data_size: 11
reading bytes data_size: 28
reading bytes data_size: 28
reading bytes data_size: 32776
reading bytes data_size: 32776
reading bytes data_size: 32776
reading bytes data_size: 32776
reading bytes data_size: 32776
reading bytes data_size: 32776
reading bytes data_size: 32776

我不清楚为什么连接会在文件中间被删除。有关如何处理这个的任何建议?

谢谢!

1 个答案:

答案 0 :(得分:0)

查看我的answer on a similar question如果它解决了这个问题,这个问题可能会被标记为重复。