httpx.ConnectError
I get the following error when running ghunt gaia [TARGET GAIA ID] from the terminal, any ideas of what the problem might be?
Traceback (most recent call last): File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/trio/_ssl.py", line 468, in _retry ret = fn(*args) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 974, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions yield File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/httpcore/backends/trio.py", line 80, in start_tls raise exc File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/httpcore/backends/trio.py", line 77, in start_tls await ssl_stream.do_handshake() File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/trio/_ssl.py", line 640, in do_handshake await self._handshook.ensure(checkpoint=True) File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/trio/_ssl.py", line 221, in ensure await self._afn(*self._args) File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/trio/_ssl.py", line 610, in _do_handshake await self._retry(self._ssl_object.do_handshake, is_handshake=True) File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/trio/_ssl.py", line 473, in _retry raise trio.BrokenResourceError from exc trio.BrokenResourceError
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions yield File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/httpx/_transports/default.py", line 353, in handle_async_request resp = await self._pool.handle_async_request(req) File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 253, in handle_async_request raise exc File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 237, in handle_async_request response = await connection.handle_async_request(request) File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/httpcore/_async/connection.py", line 86, in handle_async_request raise exc File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/httpcore/_async/connection.py", line 63, in handle_async_request stream = await self._connect(request) File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/httpcore/_async/connection.py", line 150, in _connect stream = await stream.start_tls(**kwargs) File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/httpcore/backends/trio.py", line 74, in start_tls with map_exceptions(exc_map): File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py", line 153, in exit self.gen.throw(typ, value, traceback) File "/Users/cboutaud/.local/pipx/venvs/ghunt/lib/python3.10/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions raise to_exc(exc) httpcore.ConnectError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/cboutaud/.local/bin/ghunt", line 8, in
I've tried using GHunt as a lib instead of calling from the terminal and using the following code, based on get_people_name.py from the examples, the script runs as expected with params_template="just_name" but runs into basically the same error as above with params_template="max_details", so I assume it's an issue with ssl when we're making concurrent calls? Still I am not sure where to look to fix this...
Here's the code based on get_people_name.py
import httpx
import trio
from ghunt.apis.peoplepa import PeoplePaHttp
from ghunt.objects.base import GHuntCreds
gaia = "[TARGET GAIA ID]"
async def get_details_from_gaia(gaia):
# This object stores all the needed credentials that GHunt uses
ghunt_creds = GHuntCreds()
# Check creds (but it doesn't crash if they are invalid)
ghunt_creds.load_creds()
# Async clientb
as_client = httpx.AsyncClient()
# Get the GHunt people api
people_api = PeoplePaHttp(ghunt_creds)
found, person = await people_api.people(as_client, gaia, params_template="max_details")
print("Found:", found)
if found:
# A specification of People API, there are different containers
# A target may not exists globally, but only in your contacts,
# so it will show you only the CONTACT container,
# with the informations you submitted.
# What we want here is the PROFILE container, with public infos.
if "PROFILE" in person.names:
print("Name:", person.names["PROFILE"].fullname)
else:
print("Not existing globally.")
# Running our async code in a non-async code
trio.run(get_details_from_gaia, gaia)
As a fix, I am currently bypassing the SSL verification with verify=False when instantiating the client in as_client = httpx.AsyncClient(), but I am not sure if that's the right permanent solution
Hi, the problem is related to your environment. Maybe you have a proxy, VPN, or anything else ?
Perhaps also on a restricted network, such as a public WiFi, job/school/university, or anything else.
The error comes from SSL not being verified, so its a client side issue from what I am aware.