Charles94jp / NameSilo-DDNS

动态域名解析程序: A python Dynamic DNS service for NameSilo, with logger, email notification, docker support, IPv6 support.
https://hub.docker.com/r/charles94jp/ddns/tags
MIT License
271 stars 24 forks source link

随机出现SSL错误导致程序卡住 #6

Closed MarvinChiang closed 2 years ago

MarvinChiang commented 2 years ago

目前我的解决方法是把./NameSilo-DDNS/DDNS restart做成定时任务 经常在日志中会各种出现SSL出错情况,类似

Traceback (most recent call last):
  File "ddns.py", line 100, in __init__
    r = httpx.get("https://www.ip138.com/", headers=self.httpHeaders, timeout=10)
  File "/usr/local/lib/python3.8/dist-packages/httpx/_api.py", line 189, in get
    return request(
  File "/usr/local/lib/python3.8/dist-packages/httpx/_api.py", line 100, in request
    return client.request(
  File "/usr/local/lib/python3.8/dist-packages/httpx/_client.py", line 802, in request
    return self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "/usr/local/lib/python3.8/dist-packages/httpx/_client.py", line 889, in send
    response = self._send_handling_auth(
  File "/usr/local/lib/python3.8/dist-packages/httpx/_client.py", line 917, in _send_handling_auth
    response = self._send_handling_redirects(
  File "/usr/local/lib/python3.8/dist-packages/httpx/_client.py", line 954, in _send_handling_redirects
    response = self._send_single_request(request)
  File "/usr/local/lib/python3.8/dist-packages/httpx/_client.py", line 990, in _send_single_request
    response = transport.handle_request(request)
  File "/usr/local/lib/python3.8/dist-packages/httpx/_transports/default.py", line 218, in handle_request
    resp = self._pool.handle_request(req)
  File "/usr/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.8/dist-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: EOF occurred in violation of protocol (_ssl.c:1131)
Charles94jp commented 2 years ago

针对程序出现各种SSL错误的情况:

  1. 如你举例中的File "ddns.py", line 100,这个是程序初始化时才会访问 https://www.ip138.com 。如果这里报错,说明程序没启动成功,程序启动几次。后续会考虑优化一下这里
  2. 获取本机IP时的ssl报错我已经优化过,不会卡住程序运行
  3. 当IP发生变动时,程序向NameSilo提交新IP时,会出现SSL错误导致程序停止,我也遇到过很多次。解决办法是配置auto_restart选项,程序会自动重启
Charles94jp commented 2 years ago

已经解决了,原因是httpx库默认不支持低版本的TLS 1.0协议 程序v2.1.0是一个稳定的版本,新版本正在筹划支持ipv6