requests-ip-rotator icon indicating copy to clipboard operation
requests-ip-rotator copied to clipboard

requests.exceptions.ConnectionError: HTTPSConnectionPool : Pool is Closed (On Some Connections)

Open Bewinxed opened this issue 3 years ago • 1 comments

Hey man, Amazing module you have here and helped me a lot, I'm getting the following error on "some" requests, any idea how to fix it?

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='', port=443): Pool is closed.`

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 258, in _get_conn
    conn = self.pool.get(block=self.block, timeout=timeout)
AttributeError: 'NoneType' object has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 692, in urlopen
    conn = self._get_conn(timeout=pool_timeout)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 261, in _get_conn
    raise ClosedPoolError(self, "Pool is closed.")
urllib3.exceptions.ClosedPoolError: HTTPSConnectionPool(host='1nml8jcdud.execute-api.eu-west-1.amazonaws.com', port=443): Pool is closed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Administrator\OneDrive - hamad.qa\Projects\GuardianGeckoBot\cloudflare.py", line 221, in cloudRequest
    response = await loop.run_in_executor(executor, partial(session.get, url=url, params=params))
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\asyncio\futures.py", line 284, in __await__
    yield self  # This tells Task to wait for completion.
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\asyncio\tasks.py", line 328, in __wakeup
    future.result()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\asyncio\futures.py", line 201, in result
    raise self._exception
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 555, in get
    return self.request('GET', url, **kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\cloudscraper\__init__.py", line 263, in request
    self.perform_request(method, url, *args, **kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\cloudscraper\__init__.py", line 182, in perform_request
    return super(CloudScraper, self).request(method, url, *args, **kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\requests_ip_rotator\ip_rotator.py", line 72, in send
    return super().send(request, stream, timeout, verify, cert, proxies)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='', port=443): Pool is closed.

Bewinxed avatar Jan 28 '22 16:01 Bewinxed

Hi @Bewinxed, really sorry for the delay on this. It looks like this is just a connection issue locally for you, though. Please let me know if this isn't the case? Thanks!

Ge0rg3 avatar May 26 '22 00:05 Ge0rg3

Hi @Bewinxed, closing as stale but please let me know if you still need help on this.

Ge0rg3 avatar Oct 07 '22 16:10 Ge0rg3

This appears to be a race condition in the underlying systems that can be worked around by immediately retrying: https://github.com/urllib3/urllib3/issues/951

xloem avatar Nov 08 '22 10:11 xloem