I have created a smart app with http access. I can call 'GET' on it via command line on my computer, but httpGet
from hub itself (one app does http call to another app on same hub) fails.
Here's http app (oauth enabled, but I'm not sure it's needed?):
definition(
name: "Helper app state",
namespace: "me.biocomp",
author: "biocomp",
description: "Testing",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
parent: "me.biocomp:Helper app",
oauth: true
)
mappings {
path("/") { action: [ GET: "readData" ] }
}
void resetData() {
atomicState.queuedData = "Some data"
}
def readData() {
return [data: atomicState.queuedData]
}
def getUri() {
log.info("getUri called")
return atomicState.uri
}
def installed() {
if(!state.accessToken){
//enable OAuth in the app settings or this call will fail
createAccessToken()
}
log.info "My getApiServerUrl() = ${getApiServerUrl}"
atomicState.uri = getFullLocalApiServerUrl() + "/?access_token=${state.accessToken}"
resetData()
}
def updated()
{
resetData()
}
Here's calling app:
definition(
name: "Helper app",
namespace: "me.biocomp",
author: "biocomp",
description: "Testing",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png"
)
preferences() {
section("S"){
app name: "childApps", appName: "Helper app state", namespace: "me.biocomp", title: "New Child App", multiple: false
}
}
void checkData()
{
def uri = getChildApps()[0].getUri();
log.info("Checking data via '${uri}'...")
def data = null
httpGet(uri, { response ->
log.info("Got http response: ${response}")
data = response.data
})
log.info("data = ${data}")
log.info("Done checking readData()...")
}
def installed()
{}
def uninstalled() {}
def updated() {
checkData()
}
This works on my laptop:
wget http://192.168.1.2/apps/api/622/?access_token=11111111-2222-3333-4444-555555555555
But this fails when I update the calling app:
app:4192020-05-29 16:59:53.781 errororg.apache.http.conn.HttpHostConnectException: Connect to 192.168.1.2:80 [/192.168.2.15] failed: Connection refused (Connection refused) on line 25 (updated)
app:4192020-05-29 16:59:53.747 infoChecking data via 'http://192.168.1.2/apps/api/622/?access_token=11111111-2222-3333-4444-555555555555'...
I tried searching around, but haven't found helpful answers.
What am I doing wrong? Thanks!