I have two versions of the program:
- Synchronous, using
requestslibrary; - Asynchronous, using
aiohttplibrary.
It is necessary to make requests to a site using SOCKS5 proxy. After installing the necessary libraries to work with SOCKS5 proxies, I tried making requests to a few sites. Everything worked fine with all sites except the necessary one. When sending a request to it, an error appeared:
0x05: Connection refused
I found the solution for the
requestslibrary in a couple minutes. But I didn't find a solution foraiohttp, so it took me several hours to find a solution on my own.I finally found a solution, so I'm going to publish solutions for each of the libraries below to help other developers save time in solving the same problem.
To make a successful request to such a site try to enable reverse DNS (rDNS). I will describe how to do it for
requestsandaiohttplibraries.requests
To enable rDNS, you need to use
socks5h://...instead ofsocks5://...in a proxy URL.requirements.txt
main.py
aiohttp
To enable rDNS, you need to pass the
rdns=Trueparameter during initialization of theProxyConnector.requirements.txt
main.py