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

URL error #29

Closed
FinlandBreakfast opened this issue Aug 9, 2018 · 0 comments
Closed

URL error #29

FinlandBreakfast opened this issue Aug 9, 2018 · 0 comments

Comments

@FinlandBreakfast
Copy link

Error
I received the following error when creating a collection of sat objects.

  File "/Users/.../lib/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/Users/.../lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Users/.../lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Users/.../lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Users/.../lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/Users/.../lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/Users/.../lib/python3.6/http/client.py", line 1392, in connect
    super().connect()
  File "/Users/.../lib/python3.6/http/client.py", line 940, in connect
    self._tunnel()
  File "/Users/.../lib/python3.6/http/client.py", line 919, in _tunnel
    message.strip()))
OSError: Tunnel connection failed: 503 Service Unavailable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "discrete_runner.py", line 122, in <module>
    batch_run.run_all()
  File "/Users/.../lib/python3.6/site-packages/mesa/batchrunner.py", line 130, in run_all
    model_vars, agent_vars = self._run_single_model(param_values, i, kwargscopy)
  File "/Users/.../lib/python3.6/site-packages/mesa/batchrunner.py", line 145, in _run_single_model
    model = self.model_cls(**kwargs)
  File "/Users/.../model.py", line 132, in __init__
    sat = Orbital(tle_object_name) #Fetches TLE from the internet by itself
  File "/Users/.../lib/python3.6/site-packages/pyorbital/orbital.py", line 142, in __init__
    line1=line1, line2=line2)
  File "/Users/.../lib/python3.6/site-packages/pyorbital/tlefile.py", line 147, in read
    return Tle(platform, tle_file=tle_file, line1=line1, line2=line2)
  File "/Users/.../lib/python3.6/site-packages/pyorbital/tlefile.py", line 198, in __init__
    self._read_tle()
  File "/Users/.../lib/python3.6/site-packages/pyorbital/tlefile.py", line 259, in _read_tle
    fid = open_func(url)
  File "/Users/.../lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/Users/.../lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/Users/.../lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/Users/.../lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/Users/.../lib/python3.6/urllib/request.py", line 1361, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/Users/.../lib/python3.6/urllib/request.py", line 1320, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error Tunnel connection failed: 503 Service Unavailable>

Solution
I believe the error is being thrown by too many https calls:

Changing lines 37-42 in pyorbital/tlefile.py to the following seemed to solve the issue.

TLE_URLS = (
            'http://www.celestrak.com/NORAD/elements/iridium.txt',
            'http://www.celestrak.com/NORAD/elements/weather.txt',
            'http://www.celestrak.com/NORAD/elements/resource.txt',
            'http://www.celestrak.com/NORAD/elements/cubesat.txt',
            'http://www.celestrak.com/NORAD/elements/stations.txt',
            'http://www.celestrak.com/NORAD/elements/sarsat.txt',
            'http://www.celestrak.com/NORAD/elements/noaa.txt')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant