HamsterKombatBot icon indicating copy to clipboard operation
HamsterKombatBot copied to clipboard

How to resolve Proxy endpoint failure : Unknown error while getting Nuxt Builds: [Errno 22]

Open arthur469 opened this issue 5 months ago • 0 comments

Resolving the Issue with Oxylabs Proxy Endpoint and aiohttp_proxy

When using a proxy provider like Oxylabs, you typically connect to your proxies using an endpoint such as isp.oxylabs.io in the format:
type://username:[email protected]:port

However, the aiohttp_proxy library cannot use such an endpoint, as converting the IP address to an integer results in an error when using the endpoint.

Solution

I resolved this issue by using Python's socket library in bot/utils/proxy.py.

Here are the modifications made:

  • In the get_proxy_dict() function, replace hostname=proxy.host with:

    hostname=socket.gethostbyname(proxy.host),
    
    
  • In the get_proxy_string() function, add a condition to handle the endpoint:

    if "isp.oxylabs.io" in proxy:
        proxy = proxy.replace("isp.oxylabs.io", socket.gethostbyname("isp.oxylabs.io")),
    
    

I am now looking for a cleaner, persistent, and non-hardcoded solution to help others facing the same issue with their proxy provider. Any ideas?

windows 11 Python 3.11.5

arthur469 avatar Sep 09 '24 10:09 arthur469