API Calls from outside network

Right… Just edited differently. I tried both IPs. Same results. I’m trying port 5051 now…

then i can only come to the conclusion that it must be hassio related.
if you restarted everything and have everything like i have and it isnt working for you it must be that.

i cant think of anything else.
the only thing i can come up with is that the api server somehow isnt started up without an error in the logs

OK, I changed the API port in appdaemon.yaml and restarted the application without errors in logs. Changed the port in my curl command. Same results. the exact error message I get is:

Failed to connect to 192.168.0.125 port 5051: Connection refused

My logs show:

starting version 3.2.4
[services.d] done.
2018-01-21 08:02:53.798150 INFO AppDaemon Version 2.1.12 starting
2018-01-21 08:02:53.798767 INFO Configuration read from: /config/appdaemon/appdaemon.yaml
2018-01-21 08:02:54.052969 INFO Starting Apps
2018-01-21 08:02:54.217485 INFO Got initial state
2018-01-21 08:02:54.220667 INFO Loading Module: /config/appdaemon/apps/hello.py
2018-01-21 08:02:54.223637 INFO Loading Object hello_world using class HelloWorld from module hello
2018-01-21 08:02:54.537586 INFO hello_world: Hello from AppDaemon
2018-01-21 08:02:54.543666 INFO hello_world: You are now ready to run Apps!
2018-01-21 08:02:54.544663 INFO Loading Module: /config/appdaemon/apps/test.py
2018-01-21 08:02:54.547480 INFO Loading Object test using class justapi from module test
2018-01-21 08:02:54.560173 INFO test: Hello from Test
2018-01-21 08:02:54.560873 INFO Loading Module: /config/appdaemon/apps/alexa_api.py
2018-01-21 08:02:54.564082 INFO Loading Object alexa_api using class alexa_api from module alexa_api
2018-01-21 08:02:54.565732 INFO Loading Module: /config/appdaemon/apps/alexa_intents.py
2018-01-21 08:02:54.568582 INFO Loading Object alexa_intents using class Alexa from module alexa_intents
2018-01-21 08:02:54.569949 INFO App initialization complete
2018-01-21 08:02:54.571515 INFO Starting dashboard
2018-01-21 08:02:54.590435 INFO Starting API
2018-01-21 08:02:54.613389 INFO Connected to Home Assistant 0.61.1

the log says it should be there. but the reaction to the curl command says that there is nothing alive there.

do you use the curl from the same device that you are working on?
and what does the curl say when you try your dashboard port (which you know is working)

Yes, I use cURL for my thermostats. See: HA controlling z-wave thermostats connected to ISY994i

I tried with the dashboard and I get results. Simply curl http://myLocalIP:5050 and the HTML of the dashboard is returned in the results as expected.

i asked if you are using a terminal on the hassio device to try to reach the api.

and i meant trying the exact same curl command you use to reach the api, just change the port to 5050 or 8123

Yes, that works too. cURL with port 8123, and I get something. Either Not Found, or Method not allowed, etc.

by the way i rather use the actual IP instead of something like myLocalIP to make sure its not a hidden DNS problem.
the exact same curl command can only give 1 response. :wink:
you should get a 404 response on 8123 and on 5050 with that exact command

With the EXACT same command but port 8123, I get “404: Not Found”. With variations, I get “405: Method not allowed”. Either way, I know the server is responding at least. I could work with that to make it work properly if needed on port 8123. The problem is that port 3030 does not even respond.

DNS is not in the picture here since I use “numeric” local IPs.

but if you get a 404 on the dashboard and the api port couldnt be found at all, allthough the logs say it should be there, i get the feeling it is somehow on a different port, or there is something else wrong somewhere.

did you do a complete restart from the device after you changed the settings? (shutdown to make sure that there are no settings cashed in memory)

now you say 3030 isnt responding. but you changed to 5051!

Using port 5050 with a simple cURL command works. cURL on Port 8123 works too.
I changed the API port back to 3030 and restarted the app. I will do a complete restart of the host…

i said that before.
just a restart from the app wont work if you change something on the appdaemon.yaml
and because others had trouble with 3030 i would suggest changing to 5051 and then do a complete restart.

I changed everything back to API port 5051. Completely rebooted my HASSio host. Sames results.

I wish someone would confirm if this is supposed to work in HASSio or not. Documentation is poor at best; it’s basically inexistent, or wrong.

the problem is that appdaemon is built by Anfrew and he never has used hassio in any way.
@frenck has created the plugin for it, he might be the only one that could tell if hassio could be blocking this somehow

i dont think that @aimc could come up with anything more then i did.
but it might be worth it to ask him if he has any clue left.

(just between us, i dont understand why someone with an IT background would chose hassio instead of normal install, hassio prevents you from complete local control, which an IT guy normally likes)

Right. But I like the Add-ons capabilities of HASSio. Makes it easy to control. I may revert back to a “regular” install later…

the same things you can use with hassio addon you can use the “regular” way.
the only thing is that they are not as ready made blocks.

i think hassio is great for people with little knowledge, but for advanced users i wouldnt advice it.
but oke, i just was curious why you had chosen hassio :wink:

I am now trying to build my own add-on. We’ll see…

My guess is that since hass.io is built on top of docker, there needs to be some way of mapping the API port from inside the container to the OS.

1 Like

hmm, now you say that. there were problems with the dashboard in the first versions from the addon as well, also about port mapping.

and since the api isnt a part that is extremely much used it could be that @frenck didnt do the same for the API port.