Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConnectionError #33

Open
JackKelly opened this issue Sep 4, 2019 · 3 comments
Open

ConnectionError #33

JackKelly opened this issue Sep 4, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@JackKelly
Copy link
Member

--------------------------------------------------------------------------
gaierror                                  Traceback (most recent call last)
~/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connection.py in _new_conn(self)
    159             conn = connection.create_connection(
--> 160                 (self._dns_host, self.port), self.timeout, **extra_kw)
    161 

~/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
     56 
---> 57     for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
     58         af, socktype, proto, canonname, sa = res

~/miniconda3/envs/pvoutput/lib/python3.7/socket.py in getaddrinfo(host, port, family, type, proto, flags)
    747     addrlist = []
--> 748     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
    749         af, socktype, proto, canonname, sa = res

gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

NewConnectionError                        Traceback (most recent call last)
~/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    602                                                   body=body, headers=headers,
--> 603                                                   chunked=chunked)
    604 

~/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    354         else:
--> 355             conn.request(method, url, **httplib_request_kw)
    356 

~/miniconda3/envs/pvoutput/lib/python3.7/http/client.py in request(self, method, url, body, headers, encode_chunked)
   1228         """Send a complete request to the server."""
-> 1229         self._send_request(method, url, body, headers, encode_chunked)
   1230 

~/miniconda3/envs/pvoutput/lib/python3.7/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
   1274             body = _encode(body, 'body')
-> 1275         self.endheaders(body, encode_chunked=encode_chunked)
   1276 

~/miniconda3/envs/pvoutput/lib/python3.7/http/client.py in endheaders(self, message_body, encode_chunked)
   1223             raise CannotSendHeader()
-> 1224         self._send_output(message_body, encode_chunked=encode_chunked)
   1225 

~/miniconda3/envs/pvoutput/lib/python3.7/http/client.py in _send_output(self, message_body, encode_chunked)
   1015         del self._buffer[:]
-> 1016         self.send(msg)
   1017 

~/miniconda3/envs/pvoutput/lib/python3.7/http/client.py in send(self, data)
    955             if self.auto_open:
--> 956                 self.connect()
    957             else:

~/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connection.py in connect(self)
    182     def connect(self):
--> 183         conn = self._new_conn()
    184         self._prepare_conn(conn)

~/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connection.py in _new_conn(self)
    168             raise NewConnectionError(
--> 169                 self, "Failed to establish a new connection: %s" % e)
    170 

NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f8788ce06d8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

MaxRetryError                             Traceback (most recent call last)
~/miniconda3/envs/pvoutput/lib/python3.7/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    448                     retries=self.max_retries,
--> 449                     timeout=timeout
    450                 )

~/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    640             retries = retries.increment(method, url, error=e, _pool=self,
--> 641                                         _stacktrace=sys.exc_info()[2])
    642             retries.sleep()

~/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
    398         if new_retry.is_exhausted():
--> 399             raise MaxRetryError(_pool, url, error or ResponseError(cause))
    400 

MaxRetryError: HTTPConnectionPool(host='data.pvoutput.org', port=80): Max retries exceeded with url: /service/r2/getbatchstatus.jsp?sid1=14776&dt=20160426&key=3f784ff6cfa27c44436f88da0c429b410687ad14&sid=68732 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8788ce06d8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))

During handling of the above exception, another exception occurred:

ConnectionError                           Traceback (most recent call last)
<ipython-input-15-4123708f25df> in <module>
      6         start_date=START_DATE,
      7         end_date=END_DATE,
----> 8         output_filename=OUTPUT_TIMESERIES_FILENAME)
      9 except Exception as e:
     10     logger.exception('Exception! %s', e)

~/dev/python/openclimatefix/solar/pvoutput/pvoutput/pvoutput.py in download_multiple_systems_to_disk(self, system_ids, start_date, end_date, output_filename, timezone, min_data_availability, use_get_batch_status_if_available)
    604                         pv_system_id,
    605                         date_ranges_to_download,
--> 606                         timezone)
    607                 else:
    608                     raise ValueError('data_service_url is not set!')

~/dev/python/openclimatefix/solar/pvoutput/pvoutput/pvoutput.py in _download_multiple_using_get_batch_status(self, output_filename, pv_system_id, date_ranges_to_download, timezone)
    675         total_rows = self._download_multiple_worker(
    676             output_filename, pv_system_id, dates_to, timezone,
--> 677             use_get_status=False)
    678 
    679         # Re-load data, sort, remove duplicate indicies, append back

~/dev/python/openclimatefix/solar/pvoutput/pvoutput/pvoutput.py in _download_multiple_worker(self, output_filename, pv_system_id, dates, timezone, use_get_status)
    715             else:
    716                 timeseries = self.get_batch_status(
--> 717                     pv_system_id, date_to=date_to_load)
    718             if timeseries.empty:
    719                 _LOG.info('system_id %d: Got empty timeseries back for %s',

~/dev/python/openclimatefix/solar/pvoutput/pvoutput/pvoutput.py in get_batch_status(self, pv_system_id, date_to, max_retries, **kwargs)
    288                 pv_system_status_text = self._api_query(
    289                     service='getbatchstatus', api_params=api_params,
--> 290                     use_data_service=True, **kwargs)
    291             except NoStatusFound:
    292                 _LOG.info(

~/dev/python/openclimatefix/solar/pvoutput/pvoutput/pvoutput.py in _api_query(self, service, api_params, wait_if_rate_limit_exceeded, use_data_service)
    781 
    782         try:
--> 783             response = get_response_func(service, api_params)
    784         except Exception as e:
    785             _LOG.exception(e)

~/dev/python/openclimatefix/solar/pvoutput/pvoutput/pvoutput.py in _get_data_service_response(self, service, api_params)
    844             self.data_service_url, 'service/r2/{}.jsp'.format(service))
    845 
--> 846         return _get_response(api_url, api_params, headers)
    847 
    848     def _check_api_params(self):

~/dev/python/openclimatefix/solar/pvoutput/pvoutput/utils.py in _get_response(api_url, api_params, headers)
     83     full_api_url = '{}?{}'.format(api_url, api_params_str)
     84     session = _get_session_with_retry()
---> 85     response = session.get(full_api_url, headers=headers)
     86     _LOG.debug(
     87         'response: status_code=%d; headers=%s',

~/miniconda3/envs/pvoutput/lib/python3.7/site-packages/requests/sessions.py in get(self, url, **kwargs)
    544 
    545         kwargs.setdefault('allow_redirects', True)
--> 546         return self.request('GET', url, **kwargs)
    547 
    548     def options(self, url, **kwargs):

~/miniconda3/envs/pvoutput/lib/python3.7/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    531         }
    532         send_kwargs.update(settings)
--> 533         resp = self.send(prep, **send_kwargs)
    534 
    535         return resp

~/miniconda3/envs/pvoutput/lib/python3.7/site-packages/requests/sessions.py in send(self, request, **kwargs)
    644 
    645         # Send the request
--> 646         r = adapter.send(request, **kwargs)
    647 
    648         # Total elapsed time of the request (approximately)

~/miniconda3/envs/pvoutput/lib/python3.7/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    514                 raise SSLError(e, request=request)
    515 
--> 516             raise ConnectionError(e, request=request)
    517 
    518         except ClosedPoolError as e:

ConnectionError: HTTPConnectionPool(host='data.pvoutput.org', port=80): Max retries exceeded with url: /service/r2/getbatchstatus.jsp?sid1=14776&dt=20160426&key=3f784ff6cfa27c44436f88da0c429b410687ad14&sid=68732 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8788ce06d8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))
@JackKelly JackKelly added the bug Something isn't working label Sep 4, 2019
@JackKelly
Copy link
Member Author

JackKelly commented Sep 4, 2019

Hmm... not sure which param in the Retry constructor to increase. I've increased read and status to 20. And I've attempted to get the urllib3 logger to show itself.

@JackKelly
Copy link
Member Author

This happened again:

2019-09-06 21:14:01,191 - pvoutput - INFO - **********************
2019-09-06 21:14:01,192 - pvoutput - INFO - system_id 2871: 1624 of 2556 (63.536776%)
2019-09-06 21:14:01,380 - pvoutput - INFO - system_id 2871: 0 missing dates already found
2019-09-06 21:14:01,553 - pvoutput - INFO - system_id 2871: Will download these date ranges: [DateRange(start_date=datetime.date(2011, 8, 30), end_date=datetime.date(2019, 8, 20))]
2019-09-06 21:14:01,554 - pvoutput - INFO - system_id 2871: Requesting date: 2019-08-20
2019-09-06 21:14:01,557 - urllib3.connectionpool - DEBUG - Starting new HTTP connection (1): data.pvoutput.org:80
2019-09-06 21:16:12,193 - pvoutput - ERROR - HTTPConnectionPool(host='data.pvoutput.org', port=80): Max retries exceeded with url: /service/r2/getbatchstatus.jsp?sid1=2871&dt=20190820&key=3f784ff6cfa27c44436f88da0c429b410687ad14&sid=68732 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fb41106b908>: Failed to establish a new connection: [Errno 110] Connection timed out'))
Traceback (most recent call last):
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/util/connection.py", line 80, in create_connection
    raise err
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/util/connection.py", line 70, 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 "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen
    chunked=chunked)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connectionpool.py", line 355, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/http/client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/http/client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/http/client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/http/client.py", line 1016, in _send_output
    self.send(msg)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/http/client.py", line 956, in send
    self.connect()
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connection.py", line 183, in connect
    conn = self._new_conn()
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fb41106b908>: Failed to establish a new connection: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/util/retry.py", line 399, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='data.pvoutput.org', port=80): Max retries exceeded with url: /service/r2/getbatchstatus.jsp?sid1=2871&dt=20190820&key=3f784ff6cfa27c44436f88da0c429b410687ad14&sid=68732 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fb41106b908>: Failed to establish a new connection: [Errno 110] Connection timed out'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jack/dev/python/openclimatefix/solar/pvoutput/pvoutput/pvoutput.py", line 783, in _api_query
    response = get_response_func(service, api_params)
  File "/home/jack/dev/python/openclimatefix/solar/pvoutput/pvoutput/pvoutput.py", line 846, in _get_data_service_response
    return _get_response(api_url, api_params, headers)
  File "/home/jack/dev/python/openclimatefix/solar/pvoutput/pvoutput/utils.py", line 87, in _get_response
    response = session.get(full_api_url, headers=headers)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='data.pvoutput.org', port=80): Max retries exceeded with url: /service/r2/getbatchstatus.jsp?sid1=2871&dt=20190820&key=3f784ff6cfa27c44436f88da0c429b410687ad14&sid=68732 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fb41106b908>: Failed to establish a new connection: [Errno 110] Connection timed out'))
2019-09-06 21:16:12,207 - pvoutput - ERROR - Exception! HTTPConnectionPool(host='data.pvoutput.org', port=80): Max retries exceeded with url: /service/r2/getbatchstatus.jsp?sid1=2871&dt=20190820&key=3f784ff6cfa27c44436f88da0c429b410687ad14&sid=68732 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fb41106b908>: Failed to establish a new connection: [Errno 110] Connection timed out'))
Traceback (most recent call last):
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/util/connection.py", line 80, in create_connection
    raise err
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/util/connection.py", line 70, 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 "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen
    chunked=chunked)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connectionpool.py", line 355, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/http/client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/http/client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/http/client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/http/client.py", line 1016, in _send_output
    self.send(msg)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/http/client.py", line 956, in send
    self.connect()
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connection.py", line 183, in connect
    conn = self._new_conn()
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fb41106b908>: Failed to establish a new connection: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/urllib3/util/retry.py", line 399, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='data.pvoutput.org', port=80): Max retries exceeded with url: /service/r2/getbatchstatus.jsp?sid1=2871&dt=20190820&key=3f784ff6cfa27c44436f88da0c429b410687ad14&sid=68732 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fb41106b908>: Failed to establish a new connection: [Errno 110] Connection timed out'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<ipython-input-15-4123708f25df>", line 8, in <module>
    output_filename=OUTPUT_TIMESERIES_FILENAME)
  File "/home/jack/dev/python/openclimatefix/solar/pvoutput/pvoutput/pvoutput.py", line 606, in download_multiple_systems_to_disk
    timezone)
  File "/home/jack/dev/python/openclimatefix/solar/pvoutput/pvoutput/pvoutput.py", line 677, in _download_multiple_using_get_batch_status
    use_get_status=False)
  File "/home/jack/dev/python/openclimatefix/solar/pvoutput/pvoutput/pvoutput.py", line 717, in _download_multiple_worker
    pv_system_id, date_to=date_to_load)
  File "/home/jack/dev/python/openclimatefix/solar/pvoutput/pvoutput/pvoutput.py", line 290, in get_batch_status
    use_data_service=True, **kwargs)
  File "/home/jack/dev/python/openclimatefix/solar/pvoutput/pvoutput/pvoutput.py", line 783, in _api_query
    response = get_response_func(service, api_params)
  File "/home/jack/dev/python/openclimatefix/solar/pvoutput/pvoutput/pvoutput.py", line 846, in _get_data_service_response
    return _get_response(api_url, api_params, headers)
  File "/home/jack/dev/python/openclimatefix/solar/pvoutput/pvoutput/utils.py", line 87, in _get_response
    response = session.get(full_api_url, headers=headers)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/home/jack/miniconda3/envs/pvoutput/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='data.pvoutput.org', port=80): Max retries exceeded with url: /service/r2/getbatchstatus.jsp?sid1=2871&dt=20190820&key=3f784ff6cfa27c44436f88da0c429b410687ad14&sid=68732 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fb41106b908>: Failed to establish a new connection: [Errno 110] Connection timed out'))

@JackKelly JackKelly reopened this Sep 7, 2019
@JackKelly
Copy link
Member Author

Ah - maybe the problem is that data.pvoutput.org is http:// not https:// and _get_session_with_retry() only mounted https://. I've added session.mount('http://...)`

JackKelly added a commit that referenced this issue Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant