在ec2上通过boto3发送zip文件时,如何避免ConnectionResetError?

时间:2019-06-17 20:15:38

标签: python amazon-web-services amazon-ec2 boto3 zipfile

我用几个脚本创建了一个zipfile,并尝试使用boto3的send_raw_email()函数将该文件发送给自己/组织中的其他人。我过去经常这样做,没有问题,但是这次我反复收到以下错误 ConnectionResetError: [Errno 104] Connection reset by peer

我不明白为什么现在会发生这种情况,因为我使用此功能已有几个月了(发送.zip或.csv文件),没有任何问题,除非附件超出了允许的文件大小AWS(具有不同的回溯)

分发此电子邮件及其zipfile附件的最佳方法是什么?

这是文件的详细信息,在执行ls -l之后显示:

-rw-rw-r-- 1 ec2-user ec2-user 409671984 Jun 17 19:46 foo_bar_file.zip

这是完整的追溯:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ec2-user/customer_reports_python/reports_utils.py", line 230, in send_report
    ses.send_raw_email(msg.as_string(), source= msg['From'], destinations=to_emails)
  File "/home/ec2-user/py3/lib64/python3.6/dist-packages/boto/ses/connection.py", line 323, in send_raw_email
    return self._make_request('SendRawEmail', params)
  File "/home/ec2-user/py3/lib64/python3.6/dist-packages/boto/ses/connection.py", line 102, in _make_request
    data=urllib.parse.urlencode(params)
  File "/home/ec2-user/py3/lib64/python3.6/dist-packages/boto/connection.py", line 1071, in make_request
    retry_handler=retry_handler)
  File "/home/ec2-user/py3/lib64/python3.6/dist-packages/boto/connection.py", line 1030, in _mexe
    raise ex
  File "/home/ec2-user/py3/lib64/python3.6/dist-packages/boto/connection.py", line 943, in _mexe
    request.body, request.headers)
  File "/usr/lib64/python3.6/http/client.py", line 1254, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1300, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1249, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1075, in _send_output
    self.send(chunk)
  File "/usr/lib64/python3.6/http/client.py", line 996, in send
    self.sock.sendall(data)
  File "/usr/lib64/python3.6/ssl.py", line 975, in sendall
    v = self.send(byte_view[count:])
  File "/usr/lib64/python3.6/ssl.py", line 944, in send
    return self._sslobj.write(data)
  File "/usr/lib64/python3.6/ssl.py", line 642, in write
    return self._sslobj.write(data)
ConnectionResetError: [Errno 104] Connection reset by peer```

0 个答案:

没有答案