skimpax / fbxosctrl

Shell tool to control some Freebox OS stuff: wifi, reboot...
GNU General Public License v3.0
29 stars 10 forks source link

Unable to register app: OSError: [Errno 101] Network is unreachable #15

Closed mjbright closed 5 years ago

mjbright commented 5 years ago

OK, this is clearly my misunderstanding, this is my 1st (well 2nd-failed) attempt at using this repo. Whilst "OSError: [Errno 101] Network is unreachable" sounds embarassingly like I'm doing something dumb I've no idea what that is.

I'm running on Ubuntu18.04 LTS, with Python 3.6.5.

I'm running command /usr/bin/python3 ./fbxosctrl.py --regapp to use the system Python which has zeroconf module installed.

It obtains the addressing and certificate files OK. Below are the contents of the addressing file: (with my hostname masked)

{
 "api_base_url": "/api/",
 "api_domain": "****.fbxos.fr",
 "api_version": "6.0",
 "port": "46736",
 "protocol": "https"
}

but then the script barfs with a network connection issue - see below. I tried pinging the address which works fine. I tried nmap on the port which says it's filtered (didn't really expect anything else!).

What's happening? What should I do to fix/debug?

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 83, in create_connection
    raise err
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
OSError: [Errno 101] Network is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 346, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 852, in _validate_conn
    conn.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 284, in connect
    conn = self._new_conn()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 150, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7fdd4e56dba8>: Failed to establish a new connection: [Errno 101] Network is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 639, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='sd4gr1i9.fbxos.fr', port=46736): Max retries exceeded with url: /api/v6/login/authorize/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fdd4e56dba8>: Failed to establish a new connection: [Errno 101] Network is unreachable',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./fbxosctrl.py", line 1204, in <module>
    rc = cli.dispatch(args)
  File "./fbxosctrl.py", line 1192, in dispatch
    return self._cmd_handlers.get(cmd, self._parser.print_help)()
  File "./fbxosctrl.py", line 564, in register_app
    resp = self._http.post(uri, data=data, no_login=True)
  File "./fbxosctrl.py", line 369, in post
    timeout=timeout if timeout is not None else self._http_timeout)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 520, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 630, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 508, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='sd4gr1i9.fbxos.fr', port=46736): Max retries exceeded with url: /api/v6/login/authorize/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fdd4e56dba8>: Failed to establish a new connection: [Errno 101] Network is unreachable',))
mjbright commented 5 years ago

OK, after experimenting with the API using httpie (and reading the docs) my problem is clearly something to do with the IP addressing and (of course) not a problem with this script as I am able to use the api when using mafreebox.freebox.fr, http and port 80 rather than the public address and https.

Modifying my addresses file to use mafreebox.freebox.fr, http and port 80 I'm able to register the app and this is fine for my use case.

It might be worth documenting these noob steps in the wiki though. Also an explanation of what's up with use of https would be good.

Closing this non-(code)issue.