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

Proxy connection failed. poe_api_wrapper.api:select_proxy:202 - Connection failed with {'http': '...'}. #124

Open
PMajesty opened this issue Mar 19, 2024 · 3 comments

Comments

@PMajesty
Copy link

I set up my own http proxy that works upon curling quora:

1

However, when I use it with this package:

2

It can't connect:

3

The stuff I hid with the blue color is the same proxy ip + port.
Am I doing something wrong or is this a bug of some sorts?

@snowby666
Copy link
Owner

image
I think its a bug. I tested with a proxy and it worked normally.

@srcao-bingo
Copy link

srcao-bingo commented Mar 20, 2024

这么设置好像行不通,需要在 api.py 中进一步修改吗?
image

2024-03-20 10:20:06.357 | WARNING | poe_api_wrapper.api:on_ws_close:296 - Connection to remote host was lost. Reconnecting...
2024-03-20 10:20:15.887 | INFO | poe_api_wrapper.api:select_proxy:126 - Connection failed with {'https': 'socks5://127.0.0.1:7890', 'http': 'socks5://127.0.0.1:7890'}. Trying 1/1 ...
2024-03-20 10:20:30.446 | WARNING | poe_api_wrapper.api:on_ws_close:296 - Connection to remote host was lost. Reconnecting...
2024-03-20 10:20:54.176 | WARNING | poe_api_wrapper.api:on_ws_close:296 - Connection to remote host was lost. Reconnecting...
Traceback (most recent call last):
File "E:\OneDrive\2-code\Source\utils\poe-api-wrapper-V2\poe_api_wrapper_v2_main.py", line 40, in
for chunk in client.send_message(bot, message):
File "C:\Users\cao.conda\envs\poe-api-wrapper\lib\site-packages\poe_api_wrapper\api.py", line 691, in send_message
self.connect_ws()
File "C:\Users\cao.conda\envs\poe-api-wrapper\lib\site-packages\poe_api_wrapper\api.py", line 280, in connect_ws
raise RuntimeError("Timed out waiting for websocket to connect.")
RuntimeError: Timed out waiting for websocket to connect.

@PMajesty
Copy link
Author

Yeah. I managed to fix the proxy problem by modifying the code a bit, but now the connection times out. I managed to work around it like this, but it is a clunky solution and it's far from perfect:

async def send_bot_message(bot_name, chat_id, text):
    global client  # Declare client as global within this function
    while True:
        try:
            response_chunks = []
            for chunk in client.send_message(bot_name, text, chatId=chat_id):
                response_chunks.append(chunk["response"])
            return ''.join(response_chunks)
        except requests.exceptions.ConnectionError:
            client = PoeApi(cookie=tokens, proxy=proxy_url)

Please take a look at this problem

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

3 participants