BingAds / BingAds-Python-SDK

Other
116 stars 162 forks source link

Sometimes catch ConnectionResetError #194

Closed pkochubey closed 2 years ago

pkochubey commented 2 years ago

Hi. Sometimes I catch errors:

I use general code for auth from SDK example, and sometimes at auth I catch this issues: Does anybody have a recommendation to fix this issue? Maybe retry auth request or any other best practices.

` During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/bing/report_requests.py", line 357, in authenticate(authorization_data) File "/opt/bing/auth_helper.py", line 50, in authenticate UserId=None File "/usr/local/lib/python3.6/dist-packages/bingads/service_client.py", line 273, in call raise ex File "/usr/local/lib/python3.6/dist-packages/bingads/service_client.py", line 265, in call response = self.service_client.soap_client.service.getattr(self.name)(*args, *kwargs) File "/usr/local/lib/python3.6/dist-packages/suds/client.py", line 521, in call return client.invoke(args, kwargs) File "/usr/local/lib/python3.6/dist-packages/suds/client.py", line 581, in invoke result = self.send(soapenv) File "/usr/local/lib/python3.6/dist-packages/suds/client.py", line 613, in send reply = self.options.transport.send(request) File "/usr/local/lib/python3.6/dist-packages/suds/transport/https.py", line 66, in send return HttpTransport.send(self, request) File "/usr/local/lib/python3.6/dist-packages/suds/transport/http.py", line 82, in send fp = self.u2open(u2request) File "/usr/local/lib/python3.6/dist-packages/suds/transport/http.py", line 132, in u2open return url.open(u2request, timeout=tm) File "/usr/lib/python3.6/urllib/request.py", line 526, in open response = self._open(req, data) File "/usr/lib/python3.6/urllib/request.py", line 544, in _open '_open', req) File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain result = func(args) File "/usr/lib/python3.6/urllib/request.py", line 1368, in https_open context=self._context, check_hostname=self._check_hostname) File "/usr/lib/python3.6/urllib/request.py", line 1327, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [Errno 104] Connection reset by peer> Thu Oct 14 12:11:17 UTC 2021 Traceback (most recent call last): File "/usr/lib/python3.6/urllib/request.py", line 1325, in do_open encode_chunked=req.has_header('Transfer-encoding')) File "/usr/lib/python3.6/http/client.py", line 1264, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/lib/python3.6/http/client.py", line 1310, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/lib/python3.6/http/client.py", line 1259, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/lib/python3.6/http/client.py", line 1038, in _send_output self.send(msg) File "/usr/lib/python3.6/http/client.py", line 976, in send self.connect() File "/usr/lib/python3.6/http/client.py", line 1425, in connect server_hostname=server_hostname) File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket _context=self, _session=session) File "/usr/lib/python3.6/ssl.py", line 817, in init self.do_handshake() File "/usr/lib/python3.6/ssl.py", line 1077, in do_handshake self._sslobj.do_handshake() File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake self._sslobj.do_handshake() OSError: [Errno 0] Error `

qitia commented 2 years ago

does retry help? this does not look like SDK itself issue.

pkochubey commented 2 years ago

does retry help?

Yes, it is helped. Yes is not an SDK issue, this is a Microsoft service\api availability issue.