Why Stripe gives me this error every few hours: Network error: ConnectionError:

Why Stripe gives me this error every few hours: Network error: ConnectionError:

我每隔几个小时就会收到以下错误。为什么?

我认为这与 Stripe 支付有关。

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.8/http/client.py", line 1348, in getresponse
    response.begin()
  File "/usr/lib/python3.8/http/client.py", line 316, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.8/http/client.py", line 285, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

在处理上述错误的过程中出现了一些其他错误:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/digital/.local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 400, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/digital/.local/lib/python3.8/site-packages/six.py", line 702, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.8/http/client.py", line 1348, in getresponse
    response.begin()
  File "/usr/lib/python3.8/http/client.py", line 316, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.8/http/client.py", line 285, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/digital/.local/lib/python3.8/site-packages/stripe/http_client.py", line 286, in request
    result = self._thread_local.session.request(
  File "/home/digital/.local/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/digital/.local/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/home/digital/.local/lib/python3.8/site-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/digital/paymentfollower.py", line 145, in paymentfollowing
    newer_charge=stripe.Charge.list(limit=1,ending_before=older_charge_data)
  File "/home/digital/.local/lib/python3.8/site-packages/stripe/api_resources/abstract/listable_api_resource.py", line 23, in list
    response, api_key = requestor.request("get", url, params)
  File "/home/digital/.local/lib/python3.8/site-packages/stripe/api_requestor.py", line 119, in request
    rbody, rcode, rheaders, my_api_key = self.request_raw(
  File "/home/digital/.local/lib/python3.8/site-packages/stripe/api_requestor.py", line 343, in request_raw
    rbody, rcode, rheaders = self._client.request_with_retries(
  File "/home/digital/.local/lib/python3.8/site-packages/stripe/http_client.py", line 151, in request_with_retries
    raise connection_error
  File "/home/digital/.local/lib/python3.8/site-packages/stripe/http_client.py", line 123, in request_with_retries
    response = self.request(method, url, headers, post_data)
  File "/home/digital/.local/lib/python3.8/site-packages/stripe/http_client.py", line 312, in request
    self._handle_request_error(e)
  File "/home/digital/.local/lib/python3.8/site-packages/stripe/http_client.py", line 364, in _handle_request_error
    raise error.APIConnectionError(msg, should_retry=should_retry)
stripe.error.APIConnectionError: Unexpected error communicating with Stripe.  If this problem persists,
let us know at support@stripe.com.

(Network error: ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))

Stack-overflow 一直说我的 post 主要是代码,我应该添加更多解释。所以我一直在重复这句话。

Stack-overflow 一直说我的 post 主要是代码,我应该添加更多解释。所以我一直在重复这句话。

stripe.max_network_retries = 2 按照评论中的建议为我解决了这个问题。