通过谷歌应用程序发送电子邮件时Django错误

时间:2011-09-01 16:56:51

标签: django nginx uwsgi

我有一个Django应用程序连接到谷歌应用程序发送电子邮件。但是,几天前我开始收到“由同行重置连接”错误。有时候它有效,有时候不行......我找不到任何理由来证明什么时候不行......我正在使用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 [error] 2221#0: *1379 readv() failed (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/”

1 个答案:

答案 0 :(得分:5)

在使用nginx关闭连接之前,您似乎没有阅读后期数据。

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