ustclug / lug-vpn-web

LUG VPN 申请系统
https://getvpn.ustclug.org/
GNU Affero General Public License v3.0
21 stars 13 forks source link

flask执行异常(light分支) #35

Open gaoyifan opened 7 years ago

gaoyifan commented 7 years ago

在后台点击pass按钮时报调用栈:

10.254.0.252 - - [19/Mar/2017 21:10:32] "POST /pass/199 HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/flask/app.py", line 2000, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/lib/python3.5/site-packages/flask/app.py", line 1991, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/lib/python3.5/site-packages/flask/app.py", line 1567, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/lib/python3.5/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python3.5/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python3.5/site-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/lib/python3.5/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python3.5/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/lib/python3.5/site-packages/flask_login.py", line 792, in decorated_view
    return func(*args, **kwargs)
  File "/srv/lugvpn-web/app/views.py", line 163, in pass_
    send_mail('Your application has passed', html, user.email)
  File "/srv/lugvpn-web/app/mail.py", line 11, in send_mail
    mail.send(msg)
  File "/usr/lib/python3.5/site-packages/flask_mail.py", line 491, in send
    with self.connect() as connection:
  File "/usr/lib/python3.5/site-packages/flask_mail.py", line 144, in __enter__
    self.host = self.configure_host()
  File "/usr/lib/python3.5/site-packages/flask_mail.py", line 158, in configure_host
    host = smtplib.SMTP(self.mail.server, self.mail.port)
  File "/usr/lib/python3.5/smtplib.py", line 251, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python3.5/smtplib.py", line 335, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python3.5/smtplib.py", line 306, in _get_socket
    self.source_address)
  File "/usr/lib/python3.5/socket.py", line 693, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.5/socket.py", line 732, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

有时间看一下吗? @zzh1996

zzh1996 commented 7 years ago

@gaoyifan SMTP服务器的域名解析失败

gaoyifan commented 7 years ago

@zzh1996 我当时也怀疑是这个原因。因此在出错后立即用web界面发了一封邮件,发送正常。

zzh1996 commented 7 years ago

@gaoyifan 就是偶然事件?DNS包丢了?

gaoyifan commented 7 years ago

@zzh1996 maybe… 先不管这个问题了,如果复现再说

gaoyifan commented 7 years ago

@zzh1996 找到问题了,light上配置的DNS是:10.254.0.253, 202.38.95.74 其中202.38.95.74是boj的DNS,独立于LUG,然而跪了..... 目前已换成202.38.93.94

gaoyifan commented 7 years ago

今天这个问题又复现了,调用栈相同,日志就不贴了。 @zzh1996 能否在发邮件时增加一个重试逻辑,失败后重试两三次?

gaoyifan commented 7 years ago

或者在邮件发送失败时撤销之前做的操作(事务)

zzh1996 commented 7 years ago

好的