首页 > paramiko模块连sftp下载文件时socket丢包?

paramiko模块连sftp下载文件时socket丢包?

python_3.4.2_amd64_windows 使用paramiko模块连接sftp服务器(windows),密码登录,下载文件时,总是在下载到3072KB左右卡住。
经过跟踪,发现其以每个数据包32KB的格式下载文件,总是在第98个包左右开始连续丢包,少则一两个,多则几百个,然后从正常传输直到传完。
经过确认,是在Transportrun方法调用self.packetizer.read_message()(继续往里直到_socket.SocketType.recv())获取数据的时候就没获取到缺少的包。
所以是什么原因导致了这种情况?如何解决?(使用paramiko往同一服务器上传文件没问题,使用FlashFXP下载文件也不会有问题)

附:因为中间丢包,paramiko中SFTPFile的下述方法一直卡在3072KB位置:

def _data_in_prefetch_buffers(self, offset):
        """
        if a block of data is present in the prefetch buffers, at the given
        offset, return the offset of the relevant prefetch buffer.  otherwise,
        return None.  this guarantees nothing about the number of bytes
        collected in the prefetch buffer so far.
        """
        #self._prefetch_data中缺少offset开始到某个位置X的信息,堆积了从X到结束的信息
        k = [i for i in self._prefetch_data.keys() if i <= offset]
        if len(k) == 0:
            return None
        index = max(k)
        buf_offset = offset - index
        if buf_offset >= len(self._prefetch_data[index]):
            # it's not here
            return None
        return index
【热门文章】
【热门文章】