-
Notifications
You must be signed in to change notification settings - Fork 100
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
Using third-party proxy Clash, ballyregan called by PoeApi cannot read proxy information from the system #41
Comments
I installed poe_api_wrapper[proxy]. My operating system is Win11, and the Python version is 3.9.12 |
Well there was no proxy at that moment. My unit test still works |
Did you enable Clash or other proxy software when testing? I keep Clash on when running the sample code. If I turn off Clash, I can't access Poe.com. |
i cant help beyond that then since it depends on ballyregan for auto-proxy method. Can you use the lib with just |
I still can't use it. client = PoeApi(token) |
他的默认代理检测器找不到clash代理,需要修改他的代码,分为两部分:
def __init__(self, cookie: str, proxy: bool=False):
self.cookie = cookie
self.formkey = None
if proxy == True and PROXY == True:
# proxies = fetch_proxy()
# for p in range(len(proxies)):
try:
self.proxy = {
"https://": "socks5:https://127.0.0.1:7890",
"https://": "socks5:https://127.0.0.1:7890",
}
self.client = Client(headers=self.HEADERS, timeout=180, proxies=self.proxy)
# logger.info(f"Connection established with {proxies[p]}")
logger.info("代理连接成功")
# break
except:
# logger.info(f"Connection failed with {proxies[p]}. Trying {p+1}/{len(proxies)} ...")
logger.error("代理错误")
sleep(1)
else:
self.proxy = None
self.client = Client(headers=self.HEADERS, timeout=180)
self.client.cookies.update({'m-b': self.cookie})
self.get_channel_settings()
logger.info("Connection established with poe.com")
self.ws_connecting = False
self.ws_connected = False
self.ws_error = False
self.active_messages = {}
self.message_queues = {}
self.current_thread = {}
self.retry_attempts = 3
self.message_generating = True
self.ws_refresh = 3
self.groups = {}
self.connect_ws()
def ws_run_thread(self):
if not self.ws.sock:
kwargs = {"sslopt": {"cert_reqs": ssl.CERT_NONE}, "http_proxy_host":"127.0.0.1", "http_proxy_port": 10808, "proxy_type": "socks5"}
self.ws.run_forever(**kwargs) 这个方法对我好用 |
@Hecbi 首先非常感谢您的分享,我今晚尝试后也能正确识别代理,不过仍存在下面这个问题 |
找到原因了,def ws_run_thread(self) 中的 "http_proxy_port"这个端口号需要修改成自己的端口。 |
请问我使用了这个代码连接上代理了但还是在response_json = self.client.get(f'{self.BASE_URL}/poe_api/settings', headers=self.HEADERS, timeout=30).json() 这一句出现错误EOF occurred in violation of protocol (_ssl.c:1129) |
请问你现在还能正常使用吗? |
|
请问你最后能用了吗?跪谢 |
不能 |
This is be fixed in v.1.5.4 |
When I run the sample code below, I get the following error:
`from poe_api_wrapper import PoeApi
token = "************"
bot = "a2"
message = "What is reverse engineering?"
client = PoeApi(token, proxy=True)
for chunk in client.send_message(bot, message):
print(chunk["response"], end="", flush=True)`
File "C:\Users\cao\AppData\Roaming\Python\Python39\site-packages\poe_api_wrapper\api.py", line 110, in init
proxies = fetch_proxy()
File "C:\Users\cao\AppData\Roaming\Python\Python39\site-packages\poe_api_wrapper\proxies.py", line 19, in fetch_proxy
proxies = fetcher.get(
File "C:\Users\cao\AppData\Roaming\Python\Python39\site-packages\ballyregan\fetcher.py", line 134, in get
proxies = self._gather(
File "C:\Users\cao\AppData\Roaming\Python\Python39\site-packages\ballyregan\fetcher.py", line 104, in _gather
raise NoProxiesFound
ballyregan.core.exceptions.NoProxiesFound: Could not find any proxies
The text was updated successfully, but these errors were encountered: