Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

httpx.ConnectError: [Errno 0] Error #27

Closed
zhouhh2017 opened this issue Sep 4, 2023 · 21 comments
Closed

httpx.ConnectError: [Errno 0] Error #27

zhouhh2017 opened this issue Sep 4, 2023 · 21 comments

Comments

@zhouhh2017
Copy link

zhouhh2017 commented Sep 4, 2023

Code:
from poe_api_wrapper import PoeApi
client = PoeApi("06oT***0o-Lg==")

Terminal:
Traceback (most recent call last):
File "C:\anaconda\lib\site-packages\httpcore_exceptions.py", line 10, in map_exceptions
yield
File "C:\anaconda\lib\site-packages\httpcore_backends\sync.py", line 62, in start_tls
raise exc
File "C:\anaconda\lib\site-packages\httpcore_backends\sync.py", line 57, in start_tls
sock = ssl_context.wrap_socket(
File "C:\anaconda\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\anaconda\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\anaconda\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
OSError: [Errno 0] Error

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\anaconda\lib\site-packages\httpx_transports\default.py", line 60, in map_httpcore_exceptions
yield
File "C:\anaconda\lib\site-packages\httpx_transports\default.py", line 218, in handle_request
resp = self._pool.handle_request(req)
File "C:\anaconda\lib\site-packages\httpcore_sync\connection_pool.py", line 262, in handle_request
raise exc
File "C:\anaconda\lib\site-packages\httpcore_sync\connection_pool.py", line 245, in handle_request
response = connection.handle_request(request)
File "C:\anaconda\lib\site-packages\httpcore_sync\http_proxy.py", line 271, in handle_request
connect_response = self._connection.handle_request(
File "C:\anaconda\lib\site-packages\httpcore_sync\connection.py", line 92, in handle_request
raise exc
File "C:\anaconda\lib\site-packages\httpcore_sync\connection.py", line 69, in handle_request
stream = self._connect(request)
File "C:\anaconda\lib\site-packages\httpcore_sync\connection.py", line 149, in _connect
stream = stream.start_tls(**kwargs)
File "C:\anaconda\lib\site-packages\httpcore_backends\sync.py", line 62, in start_tls
raise exc
File "C:\anaconda\lib\contextlib.py", line 131, in exit
self.gen.throw(type, value, traceback)
File "C:\anaconda\lib\site-packages\httpcore_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ConnectError: [Errno 0] Error

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\anaconda\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\anaconda\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "c:\Users\22339.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy_main
.py", line 39, in
cli.main()
File "c:\Users\22339.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main
run()
File "c:\Users\22339.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file
runpy.run_path(target, run_name="main")
File "c:\Users\22339.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
File "c:\Users\22339.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "c:\Users\22339.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "C:\desk***\PoeAPI2.py", line 3, in
client = PoeApi("06****AB0o-Lg==")
File "C:\anaconda\lib\site-packages\poe_api_wrapper\api.py", line 53, in init
'Quora-Formkey': self.get_formkey(),
File "C:\anaconda\lib\site-packages\poe_api_wrapper\api.py", line 60, in get_formkey
response = self.client.get(self.BASE_URL, headers=self.HEADERS, follow_redirects=True)
File "C:\anaconda\lib\site-packages\httpx_client.py", line 1041, in get
return self.request(
File "C:\anaconda\lib\site-packages\httpx_client.py", line 814, in request
return self.send(request, auth=auth, follow_redirects=follow_redirects)
File "C:\anaconda\lib\site-packages\httpx_client.py", line 901, in send
response = self._send_handling_auth(
File "C:\anaconda\lib\site-packages\httpx_client.py", line 929, in _send_handling_auth
response = self._send_handling_redirects(
File "C:\anaconda\lib\site-packages\httpx_client.py", line 966, in _send_handling_redirects
response = self._send_single_request(request)
File "C:\anaconda\lib\site-packages\httpx_client.py", line 1002, in _send_single_request
response = transport.handle_request(request)
File "C:\anaconda\lib\site-packages\httpx_transports\default.py", line 218, in handle_request
resp = self._pool.handle_request(req)
File "C:\anaconda\lib\contextlib.py", line 131, in exit
self.gen.throw(type, value, traceback)
File "C:\anaconda\lib\site-packages\httpx_transports\default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ConnectError: [Errno 0] Error

@snowby666
Copy link
Owner

This error could have stem from network connectivity.

@snowby666
Copy link
Owner

I think you should check if you're using proxy or a VPN while running this code

@zhouhh2017
Copy link
Author

Yes, but website of POE works well. I use clash for windows to connect VPN, TUN mode Opened already.

@zhouhh2017
Copy link
Author

client = PoeApi("0B0o-Lg==", proxy=True)
Reports:
TypeError: init() got an unexpected keyword argument 'proxy'

@snowby666
Copy link
Owner

snowby666 commented Sep 4, 2023

Then I think you are missing client certificate. Can you try installing this package:

pip install tls_client

@zhouhh2017
Copy link
Author

already satisfied

@snowby666
Copy link
Owner

How about the token? Did you get it from the quora.com or poe.com

@zhouhh2017
Copy link
Author

quora.com ,I registered it today. What's the relationship between them?

@snowby666
Copy link
Owner

Well then can you specify your python version and operating system?

@zhouhh2017
Copy link
Author

Python 3.8.5 Win10

@snowby666
Copy link
Owner

first try updating httpx library and see if that works:

pip install -U httpx

@zhouhh2017
Copy link
Author

Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Requirement already satisfied: httpx in c:\anaconda\lib\site-packages (0.24.1)
Requirement already satisfied: sniffio in c:\anaconda\lib\site-packages (from httpx) (1.3.0)
Requirement already satisfied: certifi in c:\anaconda\lib\site-packages (from httpx) (2023.5.7)
Requirement already satisfied: httpcore<0.18.0,>=0.15.0 in c:\anaconda\lib\site-packages (from httpx) (0.17.3)
Requirement already satisfied: idna in c:\anaconda\lib\site-packages (from httpx) (3.4)
Requirement already satisfied: anyio<5.0,>=3.0 in c:\anaconda\lib\site-packages (from httpcore<0.18.0,>=0.15.0->httpx) (4.0.0)
Requirement already satisfied: h11<0.15,>=0.13 in c:\anaconda\lib\site-packages (from httpcore<0.18.0,>=0.15.0->httpx) (0.14.0)
Requirement already satisfied: exceptiongroup>=1.0.2 in c:\anaconda\lib\site-packages (from anyio<5.0,>=3.0->httpcore<0.18.0,>=0.15.0->httpx) (1.1.3)

@zhouhh2017
Copy link
Author

I come from here ading2210/poe-api, is it killed by the POE team?

@snowby666
Copy link
Owner

I come from here ading2210/poe-api, is it killed by the POE team?

Not actually. But the poe team made it harder to catch up with by introducing cloudflare and other methods to prevent sending automation requests to their main api.

@snowby666
Copy link
Owner

for now its really hard for me to understand the problem you're facing. This could be a problem with the httpx library or your computer is missing SSL certificate or something.

@zhouhh2017
Copy link
Author

Maybe because of pip?

pip3 install -U poe-api-wrapper
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Requirement already satisfied: poe-api-wrapper in c:\anaconda\lib\site-packages (1.0.3)
Collecting poe-api-wrapper
Downloading http://mirrors.aliyun.com/pypi/packages/3c/aa/b45c79e55752c8c7dfcd2ca78a1b09b0e4a9865e22b928f6e89ea07bcf8e/poe_api_wrapper-1.1.8-py3-none-any.whl (38 kB)
Requirement already satisfied: keyboard in c:\anaconda\lib\site-packages (from poe-api-wrapper) (0.13.5)
Requirement already satisfied: websocket-client in c:\anaconda\lib\site-packages (from poe-api-wrapper) (1.6.1)
Collecting requests-toolbelt
Downloading http://mirrors.aliyun.com/pypi/packages/3f/51/d4db610ef29373b879047326cbf6fa98b6c1969d6f6dc423279de2b1be2c/requests_toolbelt-1.0.0-py2.py3-none-any.whl (54 kB)
---------------------------------------- 54.5/54.5 KB 189.1 kB/s eta 0:00:00
Requirement already satisfied: httpx==0.24.1 in c:\anaconda\lib\site-packages (from poe-api-wrapper) (0.24.1)
Collecting poe-api-wrapper
Downloading http://mirrors.aliyun.com/pypi/packages/65/d6/56975da1dee5977aaa6ee332600a7ef33c4d22058da1309255b6180cc494/poe_api_wrapper-1.1.7-py3-none-any.whl (37 kB)
Downloading http://mirrors.aliyun.com/pypi/packages/eb/84/6c01dfbc54c733a7a2ab20fef61918d02af59b0c6a3d4687b8c369ce8933/poe_api_wrapper-1.1.6-py3-none-any.whl (36 kB)
Downloading http://mirrors.aliyun.com/pypi/packages/5e/e1/8ab65f786973a30d031d4a2ed88fac3ebf79c43f4a44c0edfdfea7dc2b15/poe_api_wrapper-1.1.5-py3-none-any.whl (35 kB)
Downloading http://mirrors.aliyun.com/pypi/packages/67/37/5cf7928a393e146a515f15a6afb9560d949252de067b821623e2f14f6664/poe_api_wrapper-1.1.4-py3-none-any.whl (35 kB)
Downloading http://mirrors.aliyun.com/pypi/packages/00/3c/51220d8a68078a18dd831bc531551da0a07a9fc9cb48cfb5a7709d00369b/poe_api_wrapper-1.1.3-py3-none-any.whl (35 kB)
Downloading http://mirrors.aliyun.com/pypi/packages/d4/eb/e77b5c276a8f67aba05a4530bd3cba977343db55834b9a6bc78372a60547/poe_api_wrapper-1.1.2-py3-none-any.whl (35 kB)
Downloading http://mirrors.aliyun.com/pypi/packages/c2/d4/5e73a33a28c003fefb1a8f856dbd05e4603f321ccd1011321898da46b5bc/poe_api_wrapper-1.1.1-py3-none-any.whl (34 kB)
Downloading http://mirrors.aliyun.com/pypi/packages/9e/62/fcd63db0041b514e3a17d89c07714c0e0a54352bdec887aa16801a12fbd7/poe_api_wrapper-1.1.0-py3-none-any.whl (33 kB)
Downloading http://mirrors.aliyun.com/pypi/packages/01/d8/e4a3774f64ec7dd4f583c394343cace30a7b5b6f378da83269a9e1a5584e/poe_api_wrapper-1.0.9-py3-none-any.whl (32 kB)
Downloading http://mirrors.aliyun.com/pypi/packages/1c/e2/9891888ee35a5adc0a06f629cf5fccb3948adf750bee2969f0e6c0e8c478/poe_api_wrapper-1.0.8-py3-none-any.whl (33 kB)
Downloading http://mirrors.aliyun.com/pypi/packages/09/f6/e345262d7c04e94982fbd0b0cfb3079ed45b7cc710c0f93b7c6062a3a14a/poe_api_wrapper-1.0.7-py3-none-any.whl (33 kB)
Downloading http://mirrors.aliyun.com/pypi/packages/01/a8/f61bfe6740f1595d8239c220a243a313199cf281c509f8364f63341cf831/poe_api_wrapper-1.0.6-py3-none-any.whl (33 kB)
Downloading http://mirrors.aliyun.com/pypi/packages/ce/73/a846a5aa5f552c4b3768bf679f18ab42f65dcb8bc2a96e332049824e8c95/poe_api_wrapper-1.0.5-py3-none-any.whl (30 kB)
Downloading http://mirrors.aliyun.com/pypi/packages/d3/5b/4e10f325e9fdcfc521e54fc4a8f7a58107cce9d99b12e257d8c46030cd35/poe_api_wrapper-1.0.4-py3-none-any.whl (30 kB)
Requirement already satisfied: idna in c:\anaconda\lib\site-packages (from httpx==0.24.1->poe-api-wrapper) (3.4)
Requirement already satisfied: httpcore<0.18.0,>=0.15.0 in c:\anaconda\lib\site-packages (from httpx==0.24.1->poe-api-wrapper) (0.17.3)
Requirement already satisfied: certifi in c:\anaconda\lib\site-packages (from httpx==0.24.1->poe-api-wrapper) (2023.5.7)
Requirement already satisfied: sniffio in c:\anaconda\lib\site-packages (from httpx==0.24.1->poe-api-wrapper) (1.3.0)
Requirement already satisfied: h11<0.15,>=0.13 in c:\anaconda\lib\site-packages (from httpcore<0.18.0,>=0.15.0->httpx==0.24.1->poe-api-wrapper) (0.14.0)
Requirement already satisfied: anyio<5.0,>=3.0 in c:\anaconda\lib\site-packages (from httpcore<0.18.0,>=0.15.0->httpx==0.24.1->poe-api-wrapper) (4.0.0)
Requirement already satisfied: exceptiongroup>=1.0.2 in c:\anaconda\lib\site-packages (from anyio<5.0,>=3.0->httpcore<0.18.0,>=0.15.0->httpx==0.24.1->poe-api-wrapper) (1.1.3)

@snowby666
Copy link
Owner

snowby666 commented Sep 4, 2023

maybe try to uninstall the library and install again:

pip3 uninstall -y poe-api-wrapper

This time try using pip instead of pip3

pip install poe-api-wrapper==1.1.9

@zhouhh2017
Copy link
Author

pip install poe-api-wrapper==1.1.9
Collecting poe-api-wrapper==1.1.9
Using cached poe_api_wrapper-1.1.9-py3-none-any.whl (38 kB)
ERROR: Could not find a version that satisfies the requirement ballyregan (from poe-api-wrapper) (from versions: none)
ERROR: No matching distribution found for ballyregan

@zhouhh2017
Copy link
Author

After updating pip, the Error changes:
pip install poe-api-wrapper==1.1.9
Collecting poe-api-wrapper==1.1.9
Obtaining dependency information for poe-api-wrapper==1.1.9 from https://files.pythonhosted.org/packages/c0/8b/9c22c96c872176e7da640d63dfd1fc8c31db3651c72ba5ea73755005c76b/poe_api_wrapper-1.1.9-py3-none-any.whl.metadata
Using cached poe_api_wrapper-1.1.9-py3-none-any.whl.metadata (16 kB)
Requirement already satisfied: httpx==0.24.1 in c:\anaconda\lib\site-packages (from poe-api-wrapper==1.1.9) (0.24.1)
INFO: pip is looking at multiple versions of poe-api-wrapper to determine which version is compatible with other requirements. This could take a while.
ERROR: Ignored the following versions that require a different python version: 0.1.0 Requires-Python >=3.9,<4.0; 0.1.1 Requires-Python >=3.9,<4.0; 0.1.2 Requires-Python >=3.9,<4.0; 0.1.3 Requires-Python >=3.9,<4.0; 0.1.4 Requires-Python >=3.9,<4.0; 0.1.5 Requires-Python >=3.9,<4.0; 0.1.6 Requires-Python >=3.9,<4.0; 0.1.7 Requires-Python >=3.9,<4.0; 0.1.8 Requires-Python >=3.9,<4.0; 0.1.9 Requires-Python >=3.9,<4.0; 1.0.0 Requires-Python >=3.9,<4.0; 1.0.1 Requires-Python >=3.9,<4.0; 1.0.2 Requires-Python >=3.9,<4.0; 1.0.3 Requires-Python >=3.9,<4.0; 1.0.4 Requires-Python >=3.9,<4.0; 1.0.5 Requires-Python >=3.9,<4.0; 1.0.6 Requires-Python >=3.9,<4.0
ERROR: Could not find a version that satisfies the requirement ballyregan (from poe-api-wrapper) (from versions: none)
ERROR: No matching distribution found for ballyregan

@snowby666
Copy link
Owner

ballyregan is a lib for auto proxy. Their python version req is 3.9+

@zhouhh2017
Copy link
Author

done with env 3.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants