-
Notifications
You must be signed in to change notification settings - Fork 18
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
API calls on LAN, offline mode #52
Comments
I can think of some ways to alleviate the problem, but i need more details on the usage scenario. |
Usage is to get informations from the API from a system in the Freebox LAN. When we fecth informations from the API SSL adress it needs an active internet connection because the system in the LAN uses this SSL API adress wich needs to be resolved by DNS. And this is resolved to the external IP of the freebox. https is hardoced here. And here too : https://github.com/stilllman/aiofreepybox/blob/41d4905e81347293832078872ed26bcfd204a2ba/aiofreepybox/aiofreepybox.py#L75 On my dev setup i removed the ssl context from the aiohttp.TCPConnector and changed the https to http and i was able to use "192.168.1.254" on port 80 to get API informations. Whitout these modifications the connection can't be established on a non SSL endpoint. On architecture point of view i don't know what's the best :
Last but not least an example to show how stupid it is to get datas from an internet API endpoint :
Both cases are valid, open a connection to API does not work when internet is down, and even when it's already opened if internet goes down call to API during link failure won't work. Situation is restored as soon as link goes up again ! |
ok so it's mostly the first case.
HA is running, tries to sync, sends the info to afpbx which fails to resolve and errors out that it can't connect... hmmm
Yeah it was, but not anymore, actually if you use the version available in #22 (the add-fbx-detect branch), it has a _DEFAULT_SSL flag that you can edit to False to force a non ssl link, but you still need to provide an ip adress otherwise it will try to resolve mafreebox.freebox.fr
If you're using the freebox dns, i guess the real issue here is on the shoulders of the freebox devs as in: I can think of ways to workaround it, but some could have drawbacks. |
mhhh did not saw that _DEFAULT_SSL flag. That would do the trick. I do not need magic things to check if we have to grab informations from LAN, or WAN or any other way, the configuration is static. The goal is to have something working LAN only, no need for internet connection to get infos from API. That flag will do it. FYI the mafreebox.freebox.fr works even when internet connection is down. So i'll be patient, wait for a pypi release but i will try also with your repo on my dev setup. I need to change the way i'm testing it to try with your repo but that's my stuff (i use a devcontainer to dev but in this devcontainer we can't change the 3rd party libs, it's overwritten at each restart of the container 😄 ) I'll give a try with venv 👍 |
ok good so the workaround could be to fallback to it if resolve fails, the api could do it by itself if using auto detection, otherwise you still have to provide a uid to make sure it's the right one.
Yes i have the same issue ahah. |
@SNoof85, please try #22 @ 90b277e it should solve your issues.
You can also manage a "fleet" of freeboxes with get_db(), and clean up entries with clean_db(). |
Just made some testing because the way we are getting informations from the API needs a active internet connection (wich is more than stupid imo !)
The API endpoint does exists on api_domain with SSL and a specified port. But when internet connection is down, we can't get anymore informations.
The API endpoint also exists in LAN on http://192.168.1.254 but without SSL...
Could we get an alternative to fetch datas from this endpoint ? Giving us some local polling instead of internet polling ?
The text was updated successfully, but these errors were encountered: