I have a function that it requests to telegram and befor, it set a proxy socks5. whene it requests, an exception is raised.
code:
def get_request_page(self, base_url: str = "https://t.me/", proxy_url=None):
url = base_url + str(self.channel.username)
if proxy_url is not None:
proxy_info = {
"http": proxy_url,
"https": proxy_url
}
response = requests.get(url=url, proxies=proxy_info, verify=certifi_location)
else:
response = requests.get(url=url, verify=certifi_location)
if response.status_code // 100 != 2:
return ""
soup = BeautifulSoup(response.content, 'html.parser')
return soup.get_text()
error: SOCKSHTTPSConnectionPool(host='t.me', port=443): Max retries exceeded with url: /solitude_comp_music (Caused by SSLError(SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1007)')))
what should I do?
I encountered the same issue with requests. After some extensive troubleshooting, I discovered that it was caused by using a higher version of urllib3.
Error-inducing versions:
requests 2.31.0
urllib3 2.2.1
Resolved versions:
requests 2.31.0
urllib3 1.26.18
Remember to ensure compatibility between requests and urllib3 versions. If you need to downgrade urllib3, you can use the following pip command:
pip install urllib3==1.26.18
Finally, test your requests again to ensure the issue has been resolved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With