Getting [Errno 110] 'Connection timed out' when trying to do get requests in python
I am able to access the below "URL" mentioned in code manually in firefox browser and see the json response as :
{
"version" : "1.0",
"email_address" : "[email protected]"
}
But when I am trying to do get request with below code I am getting connection timeout error.
import requests
URL='https://deviceconfig.pod1.pie.avatar.ext.hp.com/virtualprinter/v1/printers/emailaddress/AQAAAAFiGLv5GQAAAAGrHfgO'
proxies = {'http': '', 'https': ''}
headers={'User-Agent':'Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0'}
try:
r= requests.get(url=URL,proxies=proxies,verify=False,headers=headers)
print r.status_code
print r.content
except requests.exceptions.RequestException as e:
print e.message
Error :
HTTPSConnectionPool(host='deviceconfig.pod1.pie.avatar.ext.hp.com', port=443): Max retries exceeded with url: /virtualprinter/v1/printers/emailaddress/AQAAAAFiGLv5GQAAAAGrHfgO (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fd9f45080d0>: Failed to establish a new connection: [Errno 110] Connection timed out',))
Now Get request is working , by setting the proxies with port number.
Added proxy setting in above code:
proxies = { 'http': 'web-proxy.xxxxxx.xx.com:8080','https': 'web-proxy.xxxxxx.xx.com:8080'}
Output :
200
{
"version" : "1.0",
"email_address" : "[email protected]"
}