通过 google apps 发送电子邮件时 Django 错误

发布于 2024-12-02 15:50:12 字数 2367 浏览 0 评论 0原文

我有一个 Django 应用程序,可以连接到 google apps 来发送电子邮件。然而,几天前我开始收到“连接被同行重置”错误。有时它有效,有时不起作用...我找不到任何理由来证明不起作用...我正在使用 nginx 和 uwsgi。有人可以帮助我了解发生了什么以及如何解决它吗?

该应用程序运行了 1 个多月,现在才开始出现此错误。

这是日志:

    Traceback (most recent call last):

 File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/handlers/base.py", line 111, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/utils/decorators.py", line 93, in _wrapped_view
   response = view_func(request, *args, **kwargs)

 File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/contrib/auth/views.py", line 155, in password_reset
   form.save(**opts)

 File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/contrib/auth/forms.py", line 147, in save
   t.render(Context(c)), from_email, [user.email])

 File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/mail/__init__.py", line 61, in send_mail
   connection=connection).send()

 File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/mail/message.py", line 251, in send
   return self.get_connection(fail_silently).send_messages([self])

 File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/mail/backends/smtp.py", line 90, in send_messages
   self.close()

 File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/mail/backends/smtp.py", line 58, in close
   self.connection.quit()

 File "/usr/lib/python2.6/smtplib.py", line 730, in quit
   res = self.docmd("quit")

 File "/usr/lib/python2.6/smtplib.py", line 363, in docmd
   return self.getreply()

 File "/usr/lib/python2.6/smtplib.py", line 337, in getreply
   line = self.file.readline()

 File "/usr/lib/python2.6/smtplib.py", line 177, in readline
   chr = self.sslobj.read(1)

 File "/usr/lib/python2.6/ssl.py", line 136, in read
   return self._sslobj.read(len)

error: [Errno 104] Connection reset by peer

nginx 日志:

2011/09/01 12:15:30 [错误] 2221#0: *1379 readv() 失败 (104:

在读取上游、客户端时,连接被对等方重置: 187.115.25.63,服务器:www.site.com,请求:“POST /ems/ HTTP/1.0",上游:"uwsgi://127.0.0.1:9001", 主机:“www.site.com”,引荐来源: “http://www.site.com/ems/”

I have a Django application that connect to google apps to send emails. However, few days ago I started to get "Connection reset by peer" error. Sometimes it works, sometimes not... I couldn't find any reason to justify when not works... I am using nginx and uwsgi. Can anybody help me to understand whats going on and how to resolve it?

This same application is running more than 1 month and just now started to give this error.

Here is the log:

    Traceback (most recent call last):

 File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/handlers/base.py", line 111, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/utils/decorators.py", line 93, in _wrapped_view
   response = view_func(request, *args, **kwargs)

 File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/contrib/auth/views.py", line 155, in password_reset
   form.save(**opts)

 File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/contrib/auth/forms.py", line 147, in save
   t.render(Context(c)), from_email, [user.email])

 File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/mail/__init__.py", line 61, in send_mail
   connection=connection).send()

 File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/mail/message.py", line 251, in send
   return self.get_connection(fail_silently).send_messages([self])

 File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/mail/backends/smtp.py", line 90, in send_messages
   self.close()

 File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/mail/backends/smtp.py", line 58, in close
   self.connection.quit()

 File "/usr/lib/python2.6/smtplib.py", line 730, in quit
   res = self.docmd("quit")

 File "/usr/lib/python2.6/smtplib.py", line 363, in docmd
   return self.getreply()

 File "/usr/lib/python2.6/smtplib.py", line 337, in getreply
   line = self.file.readline()

 File "/usr/lib/python2.6/smtplib.py", line 177, in readline
   chr = self.sslobj.read(1)

 File "/usr/lib/python2.6/ssl.py", line 136, in read
   return self._sslobj.read(len)

error: [Errno 104] Connection reset by peer

nginx log:

2011/09/01 12:15:30 [error] 2221#0: *1379 readv() failed (104:

Connection reset by peer) while reading upstream, client:
187.115.25.63, server: www.site.com, request: "POST
/ems/ HTTP/1.0", upstream: "uwsgi://127.0.0.1:9001",
host: "www.site.com", referrer:
"http://www.site.com/ems/"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悲念泪 2024-12-09 15:50:12

看起来您在关闭与 nginx 的连接之前没有读取后期数据。

如果您无法修改您的应用程序,请尝试将 --post-buffering 8192 添加到您的 uWSGI 命令行中,以强制 UWSGI 自动读取后期数据

It looks like you are not reading post-data before closing the connection with nginx.

If you cannot modify your app try adding --post-buffering 8192 to your uWSGI command line to force UWSGI reading post-data automatically

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文