Related
I running on Heroku and am getting this error SSLError with requests when sending a request out to an API any Ideas? I beielve this is a issue with my cert or the way I make a connection with requests
Here is my code and error, obviously code is just the just the calls used, and shorted up.
Here is URL used in settings.py
//settings.py
KONNEKTIVE_BASE_URL = 'https://api.konnektive.com/'
Here is api integrations class NEWKonnektive that is used in to call GET request from requests
//konnektive.py
from wrapper import Request
import logging
logger = logging.getLogger(__name__)
class NEWKonnektive(Request):
params = {}
def __init__(self):
self.auth_params = {
'loginId': os.getenv("KONNEKTIVE_USERNAME"),
'password': os.getenv("KONNEKTIVE_PASSWORD")
}
def import_click(self, *args, **kwargs):
function_name = currentframe().f_back.f_code.co_name
self.url = settings.KONNEKTIVE_BASE_URL + 'landers/clicks/import'
self.params = {}
page_type = self.set_param_or_none(kwargs, 'pageType', 'page_type', list_var=PAGE_TYPE_LIST)
if page_type is None: return False
ip_address = self.set_param_or_none(kwargs, 'ipAddress', 'ip_address')
user_agent = self.set_param_or_none(kwargs, 'userAgent', 'user_agent')
campaign_id = self.set_param_or_none(kwargs, 'campaignId', 'campaign_id')
request_uri = self.set_param_or_none(kwargs, 'requestUri', 'request_uri')
session_id = self.set_param_or_none(kwargs, 'sessionId', 'session_id')
if not session_id and (not (ip_address and campaign_id and request_uri)):
logger.error("Konnektive {}: session_id={}, ip_address={}, campaign_id={}, request_uri={}".format(function_name, session_id, ip_address, campaign_id, request_uri))
return False
response = self.get(params=self.params)
logger.info("Konnektive Import Click Response: {}".format(response))
return response
Here is api integrations class NEWKonnektive that is used in to call GET request from requests
// request wrapper.py
import json
import requests
import logging
logger = logging.getLogger(__name__)
HEADERS = {'Content-type': 'application/json'} # Default headers
class Request:
def get(self, params=None):
if not self.auth_params or not self.url:
return
if not params:
params = {}
params.update(self.auth_params)
response = requests.get(self.url, params=params, headers=HEADERS)
logger.info('response url: {}'.format(self.url))
logger.info('response: {}'.format(response))
logger.info('response.ok: {}'.format(response.ok))
logger.info('response.content: {}'.format(response.content))
logger.info('response.header: {}'.format(response.headers))
logger.info('response.url: {}'.format(response.url))
return response.content
current error appearing in New Relic:
// Error logs
Error message
requests.exceptions:SSLError: HTTPSConnectionPool(host='api.konnektive.com', port=443): Max retries exceeded with url: /landers/clicks/import?pageType=leadPage&ipAddress=73.160.94.162&campaignId=1&requestUri=https%3A%2F%2Fwww.workoutwarriors.com%2Fcontact%2F&loginId=**********&password=********** (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),))
Sample stack trace
Traceback (most recent call last):
File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 203, in run
File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 72, in run
File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 202, in run
File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 544, in manage_workers
File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 611, in spawn_workers
File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 131, in init_process
File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 124, in run
File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 68, in run_for_one
File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 30, in accept
File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 135, in handle
File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 176, in handle_request
File "/app/.heroku/python/lib/python3.6/site-packages/newrelic/api/web_transaction.py", line 1280, in _nr_wsgi_application_wrapper_
File "/app/.heroku/python/lib/python3.6/site-packages/newrelic/api/web_transaction.py", line 807, in __init__
File "/app/.heroku/python/lib/python3.6/site-packages/newrelic/api/web_transaction.py", line 1169, in _nr_wsgi_application_wrapper_
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 177, in __call__
File "/app/.heroku/python/lib/python3.6/site-packages/newrelic/hooks/framework_django.py", line 423, in _nr_wrapper_BaseHandler_get_response_
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 123, in get_response
File "/app/.heroku/python/lib/python3.6/site-packages/newrelic/hooks/framework_django.py", line 220, in wrapper
File "/app/wow/middleware/tracking.py", line 35, in process_request
File "/app/wow/middleware/tracking.py", line 64, in set_url_parameters_in_session
File "/app/integrations/konnektive.py", line 1100, in konnektive_import_click
File "/app/integrations/konnektive.py", line 298, in import_click
File "/app/integrations/wrapper.py", line 17, in get
File "/app/.heroku/python/lib/python3.6/site-packages/requests/api.py", line 72, in get
File "/app/.heroku/python/lib/python3.6/site-packages/newrelic/api/external_trace.py", line 61, in dynamic_wrapper
File "/app/.heroku/python/lib/python3.6/site-packages/newrelic/api/coroutine_trace.py", line 171, in return_value
File "/app/.heroku/python/lib/python3.6/site-packages/newrelic/api/external_trace.py", line 61, in <lambda>
File "/app/.heroku/python/lib/python3.6/site-packages/requests/api.py", line 58, in request
File "/app/.heroku/python/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
File "/app/.heroku/python/lib/python3.6/site-packages/newrelic/api/external_trace.py", line 61, in dynamic_wrapper
File "/app/.heroku/python/lib/python3.6/site-packages/newrelic/api/coroutine_trace.py", line 171, in return_value
File "/app/.heroku/python/lib/python3.6/site-packages/newrelic/api/external_trace.py", line 61, in <lambda>
File "/app/.heroku/python/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
File "/app/.heroku/python/lib/python3.6/site-packages/requests/adapters.py", line 506, in send
My cert isn't invalid right? I am using the default ACM cert Heroku gives out if you are using a custom domain.
SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)")
this is how i checked:
openssl s_client -connect “workoutwarriors.com:443” -showcerts -servername “workoutwarriors.com”
Traceback (most recent call last):
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 349, in _make_request
conn.request(method, url, **httplib_request_kw)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\http\client.py", line 1088, in request
self._send_request(method, url, body, headers)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\http\client.py", line 1126, in _send_request
self.endheaders(body)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\http\client.py", line 1084, in endheaders
self._send_output(message_body)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\http\client.py", line 922, in _send_output
self.send(msg)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\http\client.py", line 857, in send
self.connect()
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\connection.py", line 155, in connect
conn = self._new_conn()
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\connection.py", line 134, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\util\connection.py", line 88, in create_connection
raise err
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\util\connection.py", line 78, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\adapters.py", line 370, in send
timeout=timeout
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 597, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\util\retry.py", line 245, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\packages\six.py", line 309, in reraise
raise value.with_traceback(tb)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 349, in _make_request
conn.request(method, url, **httplib_request_kw)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\http\client.py", line 1088, in request
self._send_request(method, url, body, headers)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\http\client.py", line 1126, in _send_request
self.endheaders(body)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\http\client.py", line 1084, in endheaders
self._send_output(message_body)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\http\client.py", line 922, in _send_output
self.send(msg)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\http\client.py", line 857, in send
self.connect()
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\connection.py", line 155, in connect
conn = self._new_conn()
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\connection.py", line 134, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\util\connection.py", line 88, in create_connection
raise err
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\util\connection.py", line 78, in create_connection
sock.connect(sa)
requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionRefusedError(10061, 'No connection could be made because the target machine actively refused it', None, 10061, None))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\SD37561\Desktop\python scripts\link_monitor.py", line 50, in
mail_alert = validate_sites(sample_dict)
File "C:\Users\SD37561\Desktop\python scripts\link_monitor.py", line 20, in validate_sites
for _site, _auth in sample_dict.items()]
File "C:\Users\SD37561\Desktop\python scripts\link_monitor.py", line 20, in
for _site, _auth in sample_dict.items()]
File "C:\Users\SD37561\Desktop\python scripts\link_monitor.py", line 14, in site_is_reachable
response = requests.get(site_url, auth=authentication)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\api.py", line 69, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "C:\Users\SD37561\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\adapters.py", line 415, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionRefusedError(10061, 'No connection could be made because the target machine actively refused it', None, 10061, None))
the error was catched by adding the except Exception for the dict traverse and now its getting handled and printing user friendly message
I've been trying to test for a user that hasn't been verified.
class TestLoginApi(TestCase):
URL = '/rest-auth/login/'
EMAIL = 'testuser#test
PASSWORD = 'password'
DATA = {'email': EMAIL, 'password': PASSWORD}
#classmethod
def setUpTestData(cls):
cls.user = get_user_model().objects.create_user(username='testuser', email=cls.EMAIL,
password=cls.PASSWORD)
def test_login_api_without_verification(self):
response = self.client.post(self.URL, self.DATA, format='json')
The "response" line throws the following error
Error
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 601, in run
testMethod()
File "/Users/docdocengineering3/GitHub/website/project/authorization/Tests/test_login.py", line 34, in test_login_api_without_verification
response = self.client.post(self.URL, self.DATA, format='json')
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/test/client.py", line 548, in post
secure=secure, **extra)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/test/client.py", line 350, in post
secure=secure, **extra)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/test/client.py", line 416, in generic
return self.request(**r)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/test/client.py", line 501, in request
six.reraise(*exc_info)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/utils/six.py", line 686, in reraise
raise value
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/utils/decorators.py", line 67, in _wrapper
return bound_func(*args, **kwargs)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/views/decorators/debug.py", line 76, in sensitive_post_parameters_wrapper
return view(request, *args, **kwargs)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/utils/decorators.py", line 63, in bound_func
return func.get(self, type(self))(*args2, **kwargs2)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/rest_auth/views.py", line 49, in dispatch
return super(LoginView, self).dispatch(*args, **kwargs)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/rest_framework/views.py", line 489, in dispatch
response = self.handle_exception(exc)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/rest_framework/views.py", line 449, in handle_exception
self.raise_uncaught_exception(exc)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/rest_framework/views.py", line 486, in dispatch
response = handler(request, *args, **kwargs)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/rest_auth/views.py", line 92, in post
self.serializer.is_valid(raise_exception=True)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/rest_framework/serializers.py", line 237, in is_valid
self._validated_data = self.run_validation(self.initial_data)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/rest_framework/serializers.py", line 435, in run_validation
value = self.validate(value)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/rest_auth/serializers.py", line 105, in validate
email_address = user.emailaddress_set.get(email=user.email)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/db/models/query.py", line 380, in get
self.model._meta.object_name
Exception: EmailAddress matching query does not exist.
I have no idea why this is happening. It isn't a setup problem as I've tried actually running the system, creating a user (not verifying) and when I "PostMan" the same link, I get the correct error back
{"non_field_errors": [ "E-mail is not verified." ] }
So it works in the actual product but not when testing. Anyone know why? Any help is greatly appreciated.
This is the only test that I can't get to work, all the rest runs correctly.
You probably have your setting EMAIL_VERIFICATION set to mandatory.
So you either change it to none in tests or manually create EmailAddress object (it's required by django-allauth when mandatory verification is on)
Im trying to get event from google calendar by python, Im using google quickstart example, I get browser opening to confirm credential but on my pc I get following error:
Traceback (most recent call last):
File "C:\Programs\Python\Python35-32\lib\site-packages\httplib2\__init__.py", line 987, in _conn_request
conn.connect()
File "C:\Programs\Python\Python35-32\lib\http\client.py", line 1252, in connect
super().connect()
File "C:\Programs\Python\Python35-32\lib\http\client.py", line 849, in connect
(self.host,self.port), self.timeout, self.source_address)
File "C:\Programs\Python\Python35-32\lib\socket.py", line 693, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Programs\Python\Python35-32\lib\socket.py", line 732, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\myUser\Documents\Python_projects\quickstart.py", line 79, in <module>
main()
File "C:\Users\myUser\Documents\Python_projects\quickstart.py", line 60, in main
credentials = get_credentials()
File "C:\Users\myUser\Documents\Python_projects\quickstart.py", line 48, in get_credentials
credentials = tools.run_flow(flow, store, flags)
File "C:\Programs\Python\Python35-32\lib\site-packages\oauth2client\util.py", line 137, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Programs\Python\Python35-32\lib\site-packages\oauth2client\tools.py", line 243, in run_flow
credential = flow.step2_exchange(code, http=http)
File "C:\Programs\Python\Python35-32\lib\site-packages\oauth2client\util.py", line 137, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Programs\Python\Python35-32\lib\site-packages\oauth2client\client.py", line 2027, in step2_exchange
headers=headers)
File "C:\Programs\Python\Python35-32\lib\site-packages\httplib2\__init__.py", line 1314, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "C:\Programs\Python\Python35-32\lib\site-packages\httplib2\__init__.py", line 1064, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "C:\Programs\Python\Python35-32\lib\site-packages\httplib2\__init__.py", line 994, in _conn_request
raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
httplib2.ServerNotFoundError: Unable to find the server at accounts.google.com
I suppose the problem is due to my proxy but where can I set proxy setting?
Thanks in advance
When i use requests.get() function in python3 using following commands
import requests
res = requests.get('http://www.gutenberg.org/cache/epub/1112/pg1112.txt')
Then python3 throws the following error:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 557, in urlopen
body=body, headers=headers)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 351, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.4/http/client.py", line 1137, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.4/http/client.py", line 1182, in _send_request
self.endheaders(body)
File "/usr/lib/python3.4/http/client.py", line 1133, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.4/http/client.py", line 963, in _send_output
self.send(msg)
File "/usr/lib/python3.4/http/client.py", line 898, in send
self.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 155, in connect
conn = self._new_conn()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 134, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 90, in create_connection
raise err
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 80, in create_connection
sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 370, in send
timeout=timeout
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 607, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 271, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.15.2', port=8000): Max retries exceeded with url: http://www.gutenberg.org/cache/epub/1112/pg1112.txt (Caused by ProxyError('Cannot connect to proxy.', TimeoutError(110, 'Connection timed out')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/requests/api.py", line 69, in get
return request('get', url, params=params, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 424, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.15.2', port=8000): Max retries exceeded with url: http://www.gutenberg.org/cache/epub/1112/pg1112.txt (Caused by ProxyError('Cannot connect to proxy.', TimeoutError(110, 'Connection timed out')))
As far as I know it says no internet connection, but my internet is working fine. So why python is throwing this error?
You can increase the timeout with (in seconds):
requests.get('http://www.gutenberg.org/cache/epub/1112/pg1112.txt', timeout=30)
Found answer using alpbert help and this thread Proxies with Python 'Requests' module
I dont have any proxy but python was still trying to detect a proxy. So i created a dict element
proxies={'http':''}
then this command worked
res = requests.get('http://www.gutenberg.org/cache/epub/1112/pg1112.txt',proxies=proxies)