簡體   English   中英

paramiko.ssh_exception.SSHException:期望來自(31,)的數據包,得到94

[英]paramiko.ssh_exception.SSHException: Expecting packet from (31,), got 94

當我使用pysftp-0.2.8將大文件發送到我的sftp服務時。 總是出現相同的錯誤:paramiko.ssh_exception.SSHException:期望來自(31,)的數據包,得到94

該文件約為1.5G,以500M傳輸時會中斷。 代碼在這里:

import pysftp
upftp=FTP(host=ftp_ip, user=ftp_name, passwd=ftp_passwd, acct=ftp_port, timeout=None)
...

try:
    upftp.storbinary('STOR %s'%obj[2], fp, 8192, self.callpecent)      
except Exception as error:
    fp.close()
    self.endit(upftp, 1, '%s,%s'%(obj[2],error), '%s,%s'%(obj[2],error)

錯誤消息在這里:

2015-03-24 09:43:05  DEBUG - Rekeying (hit 32729 packets, 536900100 bytes sent)

2015-03-24 09:43:05  DEBUG - Ciphers agreed: local=aes128-ctr, remote=aes128-ctr
2015-03-24 09:43:05  DEBUG - using kex diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none
2015-03-24 09:43:05  ERROR - Exception: Expecting packet from (31,), got 94
2015-03-24 09:43:05  ERROR - Traceback (most recent call last):
2015-03-24 09:43:05  ERROR -   File "D:\Python34\lib\site-packages\paramiko-1.14.0-py3.4.egg\paramiko\transport.py", line 1435, in run
2015-03-24 09:43:05  ERROR -     raise SSHException('Expecting packet from %r, got %d' % (self._expected_packet, ptype))
2015-03-24 09:43:05  ERROR - paramiko.ssh_exception.SSHException: Expecting packet from (31,), got 94
2015-03-24 09:43:05  ERROR - 
2015-03-24 09:43:05  DEBUG - Dropping user packet because connection is dead.
2015-03-24 09:43:05  DEBUG - [chan 1] close(b'd40b000000000000')
2015-03-24 09:43:05  INFO - [chan 1] sftp session closed.

謝謝您的回答 !

我有一個類似的問題-事實證明,這與Paramiko一樣。 我在https://github.com/paramiko/paramiko/issues/175#issuecomment-24125451的GitHub上找到了解決方案。 也有點相似。

另一個答案指出了正在發生的事情,但沒有給予太多幫助。 對我來說,解決方法歸結為...

self.ssh_client.connect(...)

# -- the important lines
transport = self.ssh_client.get_transport()
transport.default_window_size = 2147483647
transport.packetizer.REKEY_BYTES = pow(2, 40)
transport.packetizer.REKEY_PACKETS = pow(2, 40)
# ---

self.sftp_client = self.ssh_client.open_sftp()
print(self.sft_client.get_channel().in_window_size)
print(sftp_connection.get_channel().in_max_packet_size)

# Output

2147483647
32768

我發現某些東西可能有用:)

in the paramiko/packet.py

REKEY_PACKETS = pow(2, 29)
REKEY_BYTES = pow(2, 29)

REKEY_PACKETS_OVERFLOW_MAX = pow(2, 29)     # Allow receiving this many packets after a re-key request before terminating
REKEY_BYTES_OVERFLOW_MAX = pow(2, 29)       # Allow receiving this many bytes after a re-key request before terminating

    def _trigger_rekey(self):
    # outside code should check for this flag
    self.__need_rekey = True

當它使用密鑰時,會出錯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM