0

Im trying to pass this error im getting while checking if sites are up with python: socks.SOCKS5Error: 0x06: TTL expired

proxies = {
    'http': 'socks5h://127.0.0.1:9050',
    'https': 'socks5h://127.0.0.1:9050'
}
with open("links.txt", "r") as text_file:
    for line in text_file.readlines():
        url = str(line).replace('\n', '')
        try:
            r = requests.get(url, proxies=proxies) 
            print(r)

        except:
            print("SOCKS5 TTL ERROR")
            pass

Im trying to just continue down list if this error occurs but it tries to handle the exception and stops my script with error instead of passing. The script returns 200 for site that is up but it stops on a site that hangs in browser as well.

1 Answer 1

1
proxies = {
    'http': 'socks5h://127.0.0.1:9050',
    'https': 'socks5h://127.0.0.1:9050'

socks proxies are not the same as http/https proxies. You can't interchange the two. you will need to use a library that specifically uses socks proxies because they are not compatible.

from wikipedia:

SOCKS operates at a lower level than HTTP proxying: SOCKS uses a handshake protocol to inform the proxy software about the connection that the client is trying to make, and then acts as transparently as possible, whereas a regular proxy may interpret and rewrite headers (say, to employ another underlying protocol, such as FTP; however, an HTTP proxy simply forwards an HTTP request to the desired HTTP server). Though HTTP proxying has a different usage model in mind, the CONNECT method allows for forwarding TCP connections; however, SOCKS proxies can also forward UDP traffic and work in reverse, while HTTP proxies cannot. HTTP proxies are traditionally more aware of the HTTP protocol, performing higher-level filtering (though that usually only applies to GET and POST methods, not the CONNECT method)

Also check out https://stem.torproject.org/ for working with Tor with Python

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .