2021-02-07 16:41:41,092 [INFO] looking up ASN range "range(1870, 2000)"
2021-02-07 16:41:41,093 [DEBUG] Starting new HTTPS connection (1): ipinfo.io:443
Traceback (most recent call last):
File "/home/klm/project/venv/lib64/python3.8/site-packages/urllib3/connectionpool.py", line 445, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/home/klm/project/venv/lib64/python3.8/site-packages/urllib3/connectionpool.py", line 440, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib64/python3.8/http/client.py", line 1347, in getresponse
response.begin()
File "/usr/lib64/python3.8/http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "/usr/lib64/python3.8/http/client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib64/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "/usr/lib64/python3.8/ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib64/python3.8/ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/klm/project/venv/lib64/python3.8/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/home/klm/project/venv/lib64/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/home/klm/project/venv/lib64/python3.8/site-packages/urllib3/util/retry.py", line 531, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/klm/project/venv/lib64/python3.8/site-packages/urllib3/packages/six.py", line 735, in reraise
raise value
File "/home/klm/project/venv/lib64/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/home/klm/project/venv/lib64/python3.8/site-packages/urllib3/connectionpool.py", line 447, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File "/home/klm/project/venv/lib64/python3.8/site-packages/urllib3/connectionpool.py", line 336, in _raise_timeout
raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='ipinfo.io', port=443): Read timed out. (read timeout=60)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "api.py", line 86, in <module>
asn_data = client.getBatchDetails([f"AS{num}" for num in bulk_asns], timeout_per_batch=60, raise_on_fail=False)
File "/home/klm/project/venv/lib64/python3.8/site-packages/ipinfo/handler.py", line 189, in getBatchDetails
response = requests.post(
File "/home/klm/project/venv/lib64/python3.8/site-packages/requests/api.py", line 119, in post
return request('post', url, data=data, json=json, **kwargs)
File "/home/klm/project/venv/lib64/python3.8/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/home/klm/project/venv/lib64/python3.8/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/home/klm/project/venv/lib64/python3.8/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/home/klm/project/venv/lib64/python3.8/site-packages/requests/adapters.py", line 529, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='ipinfo.io', port=443): Read timed out. (read timeout=60)
There seems to currently be a problem with a
/batchendpoint of the backend API. When the endpoint is used to lookup an ASN which according to the/<ASN>/jsonendpoint "Can't be found" it seems to hang.I have raised an issue regarding this with your support team and they suggested that I also open an issue here since it can be somewhat handled gracefully in this library.
When fetching the problematic ASNs via
getBatchDetailsit just hangs until thetimeout_per_batchvalue is exceeded and then throws an exception (see stacktrace below)Stacktrace
The error itself seems to occur at line 189 of handler.py (https://github.com/ipinfo/python/blob/master/ipinfo/handler.py#L189
I've taken a snapshot of the local variables at the time of the call to
requests.poston line 189:Local varstack
{ "batch_size": 1000, "chunk": ["AS1870", "AS1871", "AS1872", "AS1873", "AS1874", "AS1875", "AS1876", "AS1877", "AS1878", "AS1879", "AS1880", "AS1881", "AS1882", "AS1883", ...], "headers": { "user-agent": "IPinfoClient/Python3/4.1.0", "accept": "application/json", "authorization": "Bearer <MY API KEY>", "content-type": "application/json" }, "i": 0, "ip_address": "AS1919", "ip_addresses": ["AS1870", "AS1871", "AS1872", "AS1873", "AS1874", "AS1875", "AS1876", "AS1877", "AS1878", "AS1879", "AS1880", "AS1881", "AS1882", "AS1883", ...], "lookup_addresses": ["AS1870", "AS1871", "AS1872", "AS1873", "AS1874", "AS1875", "AS1876", "AS1877", "AS1878", "AS1879", "AS1880", "AS1881", "AS1882", "AS1883", ...], "raise_on_fail": False }My input arguments to
getBatchDetailswere:ip_addresses:
["AS1870", ..., "AS1919"](all 50 between those values)timeout_per_batch:
60raise_on_fail:
FalseI have been able to bypass this problem by making individual calls to
getDetailsin the meantime. However, being able to usegetBatchDetailswould be preferable to reduce network overhead.I do believe that once the issue with
/batchhas been resolved with the main API that this would likely sort itself but there could be handling for therequests.postfailing to catch erroneous cases perhaps?Thanks