appid:Dyt6WVahGR7u3bHoOmmMX2oD-gzGzoHsz
问题描述:在云引擎中使用python sdk操作数据库时,频繁报api.cn-n1.tds的连接错误,例如:{'REMOTE_ADDR': '10.30.226.23', 'REMOTE_PORT': '50200', 'HTTP_HOST': 'api.cn-n1.tds', (hidden keys: 42)} failed with ConnectionError
。
无论是afterSave函数或者find函数调用时都可能出现,高峰期一天内出现的概率高达40%,然而在小程序的js sdk使用时就没有这个问题,几乎没发现报错的情况。请问是什么原因?去年开始就有,现在越来越严重了。
python sdk版本leancloud2.9.12
下面这个是在afterSave里出现的(还没运行到我代码呢)
Traceback (most recent call last):[2024-02-29T10:35:46.978314000Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/urllib3/connectionpool.py", line 793, in urlopen[2024-02-29T10:35:46.978320400Z][instance:web1] response = self.makerequest([2024-02-29T10:35:46.978323500Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/urllib3/connectionpool.py", line 537, in makerequest[2024-02-29T10:35:46.978327000Z][instance:web1] response = conn.getresponse()[2024-02-29T10:35:46.978329900Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/urllib3/connection.py", line 466, in getresponse[2024-02-29T10:35:46.978333200Z][instance:web1] httplib_response = super().getresponse()[2024-02-29T10:35:46.978336000Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/http/client.py", line 1377, in getresponse[2024-02-29T10:35:46.978339000Z][instance:web1] response.begin()[2024-02-29T10:35:46.978342000Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/http/client.py", line 320, in begin[2024-02-29T10:35:46.978344700Z][instance:web1] version, status, reason = self.readstatus()[2024-02-29T10:35:46.978347800Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/http/client.py", line 281, in readstatus[2024-02-29T10:35:46.978350800Z][instance:web1] line = str(self.fp.readline(MAXLINE + 1), "iso-8859-1")[2024-02-29T10:35:46.978353700Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/socket.py", line 704, in readinto[2024-02-29T10:35:46.978356700Z][instance:web1] return self.sock.recv_into(b)[2024-02-29T10:35:46.978506800Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/gevent/_socketcommon.py", line 688, in recv_into[2024-02-29T10:35:46.978523000Z][instance:web1] return self.sock.recvinto(args)[2024-02-29T10:35:46.978527500Z][instance:web1] ConnectionResetError: [Errno 104] Connection reset by peer[2024-02-29T10:35:46.978530600Z][instance:web1] [2024-02-29T10:35:46.978533400Z][instance:web1] During handling of the above exception, another exception occurred:[2024-02-29T10:35:46.978597600Z][instance:web1] [2024-02-29T10:35:46.978635500Z][instance:web1] Traceback (most recent call last):[2024-02-29T10:35:46.978654000Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/requests/adapters.py", line 486, in send[2024-02-29T10:35:46.978657800Z][instance:web1] resp = conn.urlopen([2024-02-29T10:35:46.978660600Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/urllib3/connectionpool.py", line 847, in urlopen[2024-02-29T10:35:46.978664700Z][instance:web1] retries = retries.increment([2024-02-29T10:35:46.978710500Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/urllib3/util/retry.py", line 470, in increment[2024-02-29T10:35:46.978716700Z][instance:web1] raise reraise(type(error), error, stacktrace)[2024-02-29T10:35:46.978719500Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/urllib3/util/util.py", line 38, in reraise[2024-02-29T10:35:46.978722600Z][instance:web1] raise value.withtraceback(tb)[2024-02-29T10:35:46.978729000Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/urllib3/connectionpool.py", line 793, in urlopen[2024-02-29T10:35:46.978732300Z][instance:web1] response = self.makerequest([2024-02-29T10:35:46.978735000Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/urllib3/connectionpool.py", line 537, in makerequest[2024-02-29T10:35:46.978738200Z][instance:web1] response = conn.getresponse()[2024-02-29T10:35:46.978741000Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/urllib3/connection.py", line 466, in getresponse[2024-02-29T10:35:46.978744000Z][instance:web1] httplib_response = super().getresponse()[2024-02-29T10:35:46.978747000Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/http/client.py", line 1377, in getresponse[2024-02-29T10:35:46.978750000Z][instance:web1] response.begin()[2024-02-29T10:35:46.978752500Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/http/client.py", line 320, in begin[2024-02-29T10:35:46.978755600Z][instance:web1] version, status, reason = self.readstatus()[2024-02-29T10:35:46.978758100Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/http/client.py", line 281, in readstatus[2024-02-29T10:35:46.978761200Z][instance:web1] line = str(self.fp.readline(MAXLINE + 1), "iso-8859-1")[2024-02-29T10:35:46.978764000Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/socket.py", line 704, in readinto[2024-02-29T10:35:46.978767400Z][instance:web1] return self.sock.recv_into(b)[2024-02-29T10:35:46.978770200Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/gevent/_socketcommon.py", line 688, in recv_into[2024-02-29T10:35:46.978773200Z][instance:web1] return self.sock.recvinto(args)[2024-02-29T10:35:46.978989600Z][instance:web1] urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))[2024-02-29T10:35:46.979000600Z][instance:web1] [2024-02-29T10:35:46.979003600Z][instance:web1] During handling of the above exception, another exception occurred:[2024-02-29T10:35:46.979006700Z][instance:web1] [2024-02-29T10:35:46.979017700Z][instance:web1] Traceback (most recent call last):[2024-02-29T10:35:46.979020800Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/gevent/pywsgi.py", line 999, in handle_one_response[2024-02-29T10:35:46.979024000Z][instance:web1] self.run_application()[2024-02-29T10:35:46.979026700Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/geventwebsocket/handler.py", line 87, in run_application[2024-02-29T10:35:46.979029800Z][instance:web1] return super(WebSocketHandler, self).run_application()[2024-02-29T10:35:46.979032600Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/gevent/pywsgi.py", line 945, in run_application[2024-02-29T10:35:46.979035600Z][instance:web1] self.result = self.application(self.environ, self.start_response)[2024-02-29T10:35:46.979038500Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/leancloud/engine/__init__.py", line 99, in call[2024-02-29T10:35:46.979041500Z][instance:web1] return self.cloud_app(environ, start_response)[2024-02-29T10:35:46.979044400Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/werkzeug/local.py", line 230, in application[2024-02-29T10:35:46.979047400Z][instance:web1] return ClosingIterator(app(environ, start_response), self.cleanup)[2024-02-29T10:35:46.979050200Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/leancloud/engine/cors.py", line 91, in call[2024-02-29T10:35:46.979053300Z][instance:web1] return self.app(environ, cors_start_response)[2024-02-29T10:35:46.979056000Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/leancloud/engine/authorization.py", line 53, in call[2024-02-29T10:35:46.979059200Z][instance:web1] return self.app(environ, start_response)[2024-02-29T10:35:46.979062000Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/leancloud/engine/leanengine.py", line 181, in call[2024-02-29T10:35:46.979065000Z][instance:web1] self.process_session(environ)[2024-02-29T10:35:46.979067600Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/leancloud/engine/leanengine.py", line 195, in process_session[2024-02-29T10:35:46.979070700Z][instance:web1] user = leancloud.User.become(session_token)[2024-02-29T10:35:46.979073500Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/leancloud/user.py", line 77, in become[2024-02-29T10:35:46.979076900Z][instance:web1] response = client.get("/users/me", params={"session_token": session_token})[2024-02-29T10:35:46.979080700Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/leancloud/client.py", line 110, in new_func[2024-02-29T10:35:46.979083800Z][instance:web1] return func(headers=headers, args, **kwargs)[2024-02-29T10:35:46.979086600Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/leancloud/client.py", line 168, in new_func[2024-02-29T10:35:46.979089700Z][instance:web1] response = func(args, **kwargs)[2024-02-29T10:35:46.979092200Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/leancloud/client.py", line 216, in get[2024-02-29T10:35:46.979095300Z][instance:web1] response = session.get([2024-02-29T10:35:46.979100400Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/requests/sessions.py", line 602, in get[2024-02-29T10:35:46.979103500Z][instance:web1] return self.request("GET", url, **kwargs)[2024-02-29T10:35:46.979106300Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/requests/sessions.py", line 589, in request[2024-02-29T10:35:46.979109400Z][instance:web1] resp = self.send(prep, **send_kwargs)[2024-02-29T10:35:46.979112200Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/requests/sessions.py", line 703, in send[2024-02-29T10:35:46.979115300Z][instance:web1] r = adapter.send(request, **kwargs)[2024-02-29T10:35:46.979117800Z][instance:web1] File "/usr/share/pyenv/versions/3.9.18/lib/python3.9/site-packages/requests/adapters.py", line 501, in send[2024-02-29T10:35:46.979120600Z][instance:web1] raise ConnectionError(err, request=request)[2024-02-29T10:35:46.979123500Z][instance:web1] requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))[2024-02-29T10:35:46.979609000Z][instance:web1] 2024-02-29T10:35:46Z {'REMOTE_ADDR': '10.30.226.23', 'REMOTE_PORT': '50200', 'HTTP_HOST': 'api.cn-n1.tds', (hidden keys: 42)} failed with ConnectionError