Timeout Error when using proxy with httplib2 in Python

837 Views Asked by At

i have a simple code that uses proxy to submit a "GET" request to google .

import httplib2

http = httplib2.Http(proxy_info = httplib2.ProxyInfo(proxy_type=3,proxy_host=myProxy, proxy_port=myPort))
resp, content = http.request("http://google.com", "GET")
print(resp)
print(content)

For some reason i get a Timeout error :

    resp, content = http.request("http://google.com", "GET")
  File "C:\Python35\lib\site-packages\httplib2\__init__.py", line 1322, in requ
st
    (response, content) = self._request(conn, authority, uri, request_uri, meth
d, body, headers, redirections, cachekey)
  File "C:\Python35\lib\site-packages\httplib2\__init__.py", line 1072, in _req
est
    (response, content) = self._conn_request(conn, request_uri, method, body, h
aders)
  File "C:\Python35\lib\site-packages\httplib2\__init__.py", line 995, in _conn
request
    conn.connect()
  File "C:\Python35\lib\http\client.py", line 849, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "C:\Python35\lib\socket.py", line 711, in create_connection
    raise err
  File "C:\Python35\lib\socket.py", line 702, in create_connection
    sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connecte
 party did not properly respond after a period of time, or established connecti
n failed because connected host has failed to respond

I'm using a valid proxy, but this module doesn't works, Does anybody knows why this happened?

1

There are 1 best solutions below

1
On

Win Error 10060 means that no connection can be made and that either the host or the connection(proxy) is at fault. Since google is virtually never down we can narrow down the problem to the proxy configuration.

Since you seemingly configured the proxy correctly (assuming you pass the right types and arugments ) you might want to check what SOCKS protocol the server additionally supports.

Either your're not passing valid values as a proxy configuration or it is the server's fault.


You could also try to diagnose with wireshark to see if any packets even make it to the server.