[Python] ConnectionResetError: [Errno 104] Connection reset by peer
python socket 编程,sftp远程读日志文件,取最后的30行返回。收到ConnectionResetError: [Errno 104] Connection reset by peer报错。
最后找到原因是send的数据size太大,服务器端重置了连接
Traceback (most recent call last):
File “s1.py”, line 63, in
data = tcpCliSock.recv(bufsize).decode()
ConnectionResetError: [Errno 104] Connection reset by peer
解决办法:把异常by pass
from socket import error as SocketError
import errno
try:
…
...
except SocketError as e:
if e.errno != errno.ECONNRESET:
raise
pass
还没有评论,来说两句吧...