sendHttpGetRequest not working under OH 2.4 M7 after Update from 2.3


(Zippochonda) #1
  • Platform information:
    • Hardware: Raspberry Pi
    • OS: Openhabian
    • Java Runtime Environment: zulu-embedded-8-armhf
    • openHAB version: OH 2.4 M7
  • Issue of the topic: sendHttpGetRequest not working under OH 2.4 M7

I have the following problem, I updated my Openhabian from version 2.3 stable to 2.4 Snapshot M7 because of problems with homematicbinding. Unfortunately my script for querying the data from my decalcifier no longer works.
Under version 2.3 it worked perfectly

The script is as follows:

val String BENUTZER= "USER"
val String PASSWORD= "PW"
val String GERAETEID= "XXXXXX"
val String JUDOIP= "192.168.178.28"
val String PORT= "8124"


rule "Judo"
when
    Item residual_hardness_setpoint changed or
    Item watervalveswitch changed or
    Time is midnight or
    Time is noon

then
logInfo("Judo","1")
	var String tokenjson = sendHttpGetRequest("https://"+ JUDOIP +":" + PORT + "?group=register&command=login&msgnumber=2&name=login&user=" + BENUTZER + "&password=" + PASSWORD + "&role=customer")

logInfo("Judo","2")
	var String TOKEN = transform("JSONPATH", "$.token", tokenjson)

logInfo("Judo","3")
	var String loginjson = sendHttpGetRequest("https://"+ JUDOIP +":" + PORT + "?group=register&command=connect&msgnumber=5&token=" + TOKEN + "&parameter=i-soft%20plus&serial%20number=" + GERAETEID)

logInfo("Judo","4")
    var String LOGINSTATUS = transform("JSONPATH", "$.status", loginjson)

    if (LOGINSTATUS == "ok")
    {
        logInfo("Judo","Login erfolgreich")

        var String wcjson = sendHttpGetRequest("https://"+ JUDOIP +":" + PORT + "?group=consumption&command=water%20current&msgnumber=1&token=" + TOKEN )
        var String var_water_current = transform("JSONPATH", "$.data", wcjson)
        water_current.postUpdate(var_water_current)

        var String wtjson = sendHttpGetRequest("https://"+ JUDOIP +":" + PORT + "?group=consumption&command=water%20total&msgnumber=1&token=" + TOKEN )
        var String var_water_total = transform("JSONPATH", "$.data", wtjson)
        var Number var_rawwater = Float::parseFloat(var_water_total.split(" ").get(1))
        var Number var_decarbonatedwater = Float::parseFloat(var_water_total.split(" ").get(2))
        water_total.postUpdate(var_water_total)
        rawwater.postUpdate(var_rawwater)
        decarbonatedwater.postUpdate(var_decarbonatedwater)

        var String wajson = sendHttpGetRequest("https://"+ JUDOIP +":" + PORT + "?group=consumption&command=water%20average&msgnumber=1&token=" + TOKEN )
        var String var_water_average = transform("JSONPATH", "$.data", wajson)
        water_average.postUpdate(var_water_average)

        var String aqjson = sendHttpGetRequest("https://"+ JUDOIP +":" + PORT + "?group=consumption&command=actual%20quantity&msgnumber=1&token=" + TOKEN )
        var String var_actual_quantity = transform("JSONPATH", "$.data", aqjson)
        actual_quantity.postUpdate(var_actual_quantity)

        var String sqjson = sendHttpGetRequest("https://"+ JUDOIP +":" + PORT + "?group=consumption&command=salt%20quantity&msgnumber=1&token=" + TOKEN )
        var String var_salt_quantity = transform("JSONPATH", "$.data", sqjson)
        salt_quantity.postUpdate(var_salt_quantity)

        var String srjson = sendHttpGetRequest("https://"+ JUDOIP +":" + PORT + "?group=consumption&command=salt%20range&msgnumber=1&token=" + TOKEN )
        var String var_salt_range = transform("JSONPATH", "$.data", srjson)
        salt_range.postUpdate(var_salt_range)

        var String rhjson = sendHttpGetRequest("https://"+ JUDOIP +":" + PORT + "?group=settings&command=residual%20hardness&msgnumber=1&token=" + TOKEN )
        var String var_residual_hardness = transform("JSONPATH", "$.data", rhjson)
        residual_hardness.postUpdate(var_residual_hardness)

        var String nhjson = sendHttpGetRequest("https://"+ JUDOIP +":" + PORT + "?group=settings&command=residual%20hardness&msgnumber=1&token=" + TOKEN )
        var String var_natural_hardness = transform("JSONPATH", "$.data", nhjson)
        natural_hardness.postUpdate(var_natural_hardness)

        var String vajson = sendHttpGetRequest("https://"+ JUDOIP +":" + PORT + "?group=waterstop&command=valve&msgnumber=1&token=" + TOKEN )
        var String var_valve = transform("JSONPATH", "$.data", vajson)
        valve.postUpdate(var_valve)

        var String wwjson = sendHttpGetRequest("https://"+ JUDOIP +":" + PORT + "?group=consumption&command=water%20weekly&msgnumber=1&token=" + TOKEN + "&year=%3CYEAR%3E&month=%3CMONTH%3E&day=%3CDAY%3E")
        var String var_water_weekly = transform("JSONPATH", "$.data", wwjson)
        var Number var_mon = Float::parseFloat(var_water_weekly.split(" ").get(1))
        var Number var_tue = Float::parseFloat(var_water_weekly.split(" ").get(2))
        var Number var_wed = Float::parseFloat(var_water_weekly.split(" ").get(3))
        var Number var_thu = Float::parseFloat(var_water_weekly.split(" ").get(4))
        var Number var_fri = Float::parseFloat(var_water_weekly.split(" ").get(5))
        var Number var_sat = Float::parseFloat(var_water_weekly.split(" ").get(6))
        var Number var_sun = Float::parseFloat(var_water_weekly.split(" ").get(7))
        water_weekly.postUpdate(var_water_weekly)
        watermon.postUpdate(var_mon)
        watertue.postUpdate(var_tue)
        waterwed.postUpdate(var_wed)
        waterthu.postUpdate(var_thu)
        waterfri.postUpdate(var_fri)
        watersat.postUpdate(var_sat)
        watersun.postUpdate(var_sun)


        var String wyjson = sendHttpGetRequest("https://"+ JUDOIP +":" + PORT + "?group=consumption&command=water%20yearly&msgnumber=1&token=" + TOKEN + "&year=%3CYEAR%3E")
        var String var_water_yearly = transform("JSONPATH", "$.data", wyjson)
        var Number var_jan = Float::parseFloat(var_water_yearly.split(" ").get(1))
        var Number var_feb = Float::parseFloat(var_water_yearly.split(" ").get(2))
        var Number var_mar = Float::parseFloat(var_water_yearly.split(" ").get(3))
        var Number var_apr = Float::parseFloat(var_water_yearly.split(" ").get(4))
        var Number var_mai = Float::parseFloat(var_water_yearly.split(" ").get(5))
        var Number var_jun = Float::parseFloat(var_water_yearly.split(" ").get(6))
        var Number var_jul = Float::parseFloat(var_water_yearly.split(" ").get(7))
        var Number var_aug = Float::parseFloat(var_water_yearly.split(" ").get(8))
        var Number var_sep = Float::parseFloat(var_water_yearly.split(" ").get(9))
        var Number var_okt = Float::parseFloat(var_water_yearly.split(" ").get(10))
        var Number var_nov = Float::parseFloat(var_water_yearly.split(" ").get(11))
        var Number var_dez = Float::parseFloat(var_water_yearly.split(" ").get(12))

        water_yearly.postUpdate(var_water_yearly)
        waterjan.postUpdate(var_jan)
        waterfeb.postUpdate(var_feb)
        watermar.postUpdate(var_mar)
        waterapr.postUpdate(var_apr)
        watermai.postUpdate(var_mai)
        waterjun.postUpdate(var_jun)
        waterjul.postUpdate(var_jul)
        wateraug.postUpdate(var_aug)
        watersep.postUpdate(var_sep)
        waterokt.postUpdate(var_okt)
        waternov.postUpdate(var_nov)
        waterdez.postUpdate(var_dez)

        if (residual_hardness_setpoint.state != residual_hardness)
            {
            var String rhsjson = sendHttpGetRequest("https://"+ JUDOIP +":" + PORT + "?group=settings&command=residual%20hardness&msgnumber=1&token=" + TOKEN + "&parameter=" + residual_hardness_setpoint.state )
            var String var_residual_hardness_status = transform("JSONPATH", "$.status", rhsjson)
            if ( var_residual_hardness_status == "ok")
                {
                var String var_residual_hardness_setpoint = transform("JSONPATH", "$.parameter", rhsjson)
                residual_hardness.postUpdate(var_residual_hardness_setpoint)
                residual_hardness_setpoint.postUpdate(var_residual_hardness_setpoint)
                }
            }


        if (watervalveswitch.state == ON && valve.state.toString.contains("opened"))
            {
            var String vsjson = sendHttpGetRequest("https://"+ JUDOIP +":" + PORT + "?group=waterstop&command=valve&msgnumber=1&token=" + TOKEN + "&parameter=close")
            logInfo("Judo","Wassersperrventil GESCHLOSSEN")
            }


        if (watervalveswitch.state == OFF && valve.state.toString.contains("closed"))
            {
            var String vsjson = sendHttpGetRequest("https://"+ JUDOIP +":" + PORT + "?group=waterstop&command=valve&msgnumber=1&token=" + TOKEN + "&parameter=open")
            logInfo("Judo","Wassersperrventil OFFEN")
            }

        }
end

I get the following error message during execution:

2018-12-06 15:57:41.011 [INFO ] [.eclipse.smarthome.model.script.Judo] - 1
2018-12-06 15:57:41.940 [ERROR] [.smarthome.model.script.actions.HTTP] - Fatal transport error: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Delegated task threw Exception/Error
2018-12-06 15:57:41.945 [INFO ] [.eclipse.smarthome.model.script.Judo] - 2
2018-12-06 15:57:41.950 [INFO ] [.eclipse.smarthome.model.script.Judo] - 3
2018-12-06 15:57:42.277 [ERROR] [.smarthome.model.script.actions.HTTP] - Fatal transport error: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Delegated task threw Exception/Error
2018-12-06 15:57:42.280 [INFO ] [.eclipse.smarthome.model.script.Judo] - 4 

If I e.g. read the token via the httpbinding it works.

Example item:

String Judotoken "Token der Judoanlage" { http="<[https://192.168.178.28:8124/?group=register&command=login&msgnumber=1&name=login&user=USER&password=PW&role=customer:600000:JSONPATH($.token)]" }

Result in Logs

2018-12-06 16:00:59.256 [vent.ItemStateChangedEvent] - Judotoken changed from 0e9850c6f39da0326903ab02f131c3c41467190b4d2e8c786ac53f0f9b6f1906 to 3f32a97e46408e305658aaa180ca12bd50612e1c0026bd6a34e3566c20aa1cb5

If you fire the link via a Webbroser you will get this result

{"group":"register","command":"login","msgnumber":"1","name":"login","user":"USER","password":"*","role":"customer","status":"ok","token":"f61078d5d8801e19edc01c5e634771f72f9f8b9fb21350579f4b875d8c33cbfb"}

(CM6.5 H102) #2

When I moved from 2.3 to 2.4 M7 on RPI 3 I noticed a few errors in the logs. I didn’t check to see if all my rules worked, but I was able to stop the errors. The fix was stopping OH, clean the cache via openhab-cli clean-cache, then rebooting. The reboot was the key, I think, b/c simply restarting OH after cleaning didn’t work.

Maybe doing the same will help?:crossed_fingers:

Best of Luck.


(Vincent Regaud) #3

You are firing http requests in very fast succession.
Maybe adding a timer between each will help


(Zippochonda) #4

Tried both,

The fix was stopping OH, clean the cache via openhab-cli clean-cache, then rebooting.

and added

Thread::sleep(3000)

after every http request, sadly i got the same result…


(Vincent Regaud) #5

Do you get the errors on the same calls?


(Zippochonda) #6

Getting the Error on every call to my decalcifier

[.smarthome.model.script.actions.HTTP] - Fatal transport error: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Delegated task threw Exception/Error

Same error with

https://192.168.178.28:8124/?group=register&command=login&msgnumber=1&name=login&user=XXXX&password=XXXXX&role=customer
https://192.168.178.28:8124?group=register&command=connect&msgnumber=5&token=16ca4a729dc2b54d4e1d0fa7e3818c2d8bb0add062a6c002a0a25f9530679adb&parameter=i-soft%20plus&serial%20number=XXX

Tried also with prefilled urls and urls with variables

The strange thing is, its working if i use the http binding for example

String Judotoken “Token der Judoanlage” { http="<[https://192.168.178.28:8124/?group=register&command=login&msgnumber=1&name=login&user=XXX&password=XXX&role=customer:600000:JSONPATH($.token)]" }

If I use a different source in the rule for a test the Var TOKEN shows the right value

var String tokenjson = sendHttpGetRequest(“https://reqres.in/api/users/2”)
var String TOKEN = transform(“JSONPATH”, “$.data.first_name”, tokenjson)

Could it be a problem with the SSL connection? Uses the http Binding different certificates than the sendHttpGetRequest in the rules?


(Vincent Regaud) #7

Does it work if you roll back to 2.3 stable?


(Zippochonda) #8

I made a 2nd system with OH 2.3 and its working

2018-12-09 21:32:07.220 [INFO ] [.eclipse.smarthome.model.script.Judo] - Login erfolgreich
==&gt; /var/log/openhab2/events.log &lt;==
2018-12-09 21:32:11.181 [vent.ItemStateChangedEvent] - water_current changed from NULL to 3 2
2018-12-09 21:32:15.416 [vent.ItemStateChangedEvent] - water_total changed from NULL to 126777 87026
2018-12-09 21:32:15.427 [vent.ItemStateChangedEvent] - rawwater changed from NULL to 126777.0
2018-12-09 21:32:15.431 [vent.ItemStateChangedEvent] - decarbonatedwater changed from NULL to 87026.0
2018-12-09 21:32:20.345 [vent.ItemStateChangedEvent] - water_average changed from NULL to 226
2018-12-09 21:32:24.750 [vent.ItemStateChangedEvent] - actual_quantity changed from NULL to 0
2018-12-09 21:32:29.654 [vent.ItemStateChangedEvent] - salt_quantity changed from NULL to 23800
2018-12-09 21:32:33.881 [vent.ItemStateChangedEvent] - salt_range changed from NULL to 150
2018-12-09 21:32:38.283 [vent.ItemStateChangedEvent] - residual_hardness changed from NULL to 8
2018-12-09 21:32:42.356 [vent.ItemStateChangedEvent] - natural_hardness changed from NULL to 8
2018-12-09 21:32:46.459 [vent.ItemStateChangedEvent] - valve changed from NULL to opened
2018-12-09 21:32:49.765 [vent.ItemStateChangedEvent] - water_weekly changed from NULL to 211 134 194 212 226 329 312
2018-12-09 21:32:49.791 [vent.ItemStateChangedEvent] - watermon changed from NULL to 211.0
2018-12-09 21:32:49.799 [vent.ItemStateChangedEvent] - watertue changed from NULL to 134.0
2018-12-09 21:32:49.803 [vent.ItemStateChangedEvent] - waterwed changed from NULL to 194.0
2018-12-09 21:32:49.813 [vent.ItemStateChangedEvent] - waterthu changed from NULL to 212.0
2018-12-09 21:32:49.817 [vent.ItemStateChangedEvent] - waterfri changed from NULL to 226.0
2018-12-09 21:32:49.827 [vent.ItemStateChangedEvent] - watersat changed from NULL to 329.0
2018-12-09 21:32:49.830 [vent.ItemStateChangedEvent] - watersun changed from NULL to 312.0
2018-12-09 21:32:55.791 [vent.ItemStateChangedEvent] - water_yearly changed from NULL to 6883 6751 6251 8418 8274 9047 10951 9161 7849 7218 6423 2147
2018-12-09 21:32:55.818 [vent.ItemStateChangedEvent] - waterjan changed from NULL to 6883.0
2018-12-09 21:32:55.847 [vent.ItemStateChangedEvent] - waterfeb changed from NULL to 6751.0
2018-12-09 21:32:55.873 [vent.ItemStateChangedEvent] - watermar changed from NULL to 6251.0
2018-12-09 21:32:55.905 [vent.ItemStateChangedEvent] - waterapr changed from NULL to 8418.0
2018-12-09 21:32:55.915 [vent.ItemStateChangedEvent] - watermai changed from NULL to 8274.0
2018-12-09 21:32:55.923 [vent.ItemStateChangedEvent] - waterjun changed from NULL to 9047.0
2018-12-09 21:32:55.935 [vent.ItemStateChangedEvent] - waterjul changed from NULL to 10951.0
2018-12-09 21:32:55.941 [vent.ItemStateChangedEvent] - wateraug changed from NULL to 9161.0
2018-12-09 21:32:55.948 [vent.ItemStateChangedEvent] - watersep changed from NULL to 7849.0
2018-12-09 21:32:55.951 [vent.ItemStateChangedEvent] - waterokt changed from NULL to 7218.0
2018-12-09 21:32:55.953 [vent.ItemStateChangedEvent] - waternov changed from NULL to 6423.0
2018-12-09 21:32:55.956 [vent.ItemStateChangedEvent] - waterdez changed from NULL to 2147.0

(Zippochonda) #9

So its working under 2.3 and NOT working under 2.4. M7. Because of the Homematic issuses i would like to stay at 2.4 M7. Is there any possibility to get more Informations on the Error

smarthome.model.script.actions.HTTP] - Fatal transport error: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Delegated task threw Exception/Error

What kind of Task threw what kind of Error?


(Martin van Wingerden) #10

Enable debug logging for org.eclipse.smarthome.io.net maybe that gives some insight, are you connecting to an http or https website?


(Zippochonda) #11

Https


(Martin van Wingerden) #12

Https, yes that could be it, did you load the certificates in your keystore?


(Martin van Wingerden) #13

Did you also try M8? There was a problem with common-names being empty on certificates


(Zippochonda) #14

Yes,
i did that. The strange thing is that it’s working with the http binding and an item. But not if i use a sendHttpGetRequest in the rule.


(Zippochonda) #15

Going to update this evening to m8, would be great if it’s solve the problem


(Martin van Wingerden) #16

No that might not be that strange, because the rules use the eclipse smarthome functions, where we changed something to handle https certificates in another way.

The http binding uses its own connection logic.


(Martin van Wingerden) #17

Great, please keep us posted and if it still fails it would be great if you could share some debug logging with us.


(Zippochonda) #18

So updated to M8, and its not working but i get a different error.

2018-12-15 10:40:13.398 [ERROR] [.smarthome.model.script.actions.HTTP] - Fatal transport error: java.util.concurrent.ExecutionException: javax.net.ssl.SSLHandshakeException: General SSLEngine problem


(Zippochonda) #19

Set it to debug logging:
2018-12-15 10:56:01.904 [INFO ] [.eclipse.smarthome.model.script.Judo] - 1

2018-12-15 10:56:01.915 [DEBUG] [t.http.internal.WebClientFactoryImpl] - shared http client requested

2018-12-15 10:56:01.918 [DEBUG] [lipse.smarthome.io.net.http.HttpUtil] - About to execute https://192.168.178.28:8124?group=register&amp;command=login&amp;msgnumber=2&amp;name=login&amp;user=xxxxx&amp;password=xxxxxxx&amp;role=customer

2018-12-15 10:56:02.105 [ERROR] [.smarthome.model.script.actions.HTTP] - Fatal transport error: java.util.concurrent.ExecutionException: javax.net.ssl.SSLHandshakeException: General SSLEngine problem

2018-12-15 10:56:02.114 [INFO ] [.eclipse.smarthome.model.script.Judo] - null

2018-12-15 10:56:02.118 [INFO ] [.eclipse.smarthome.model.script.Judo] - 2

2018-12-15 10:56:05.134 [INFO ] [.eclipse.smarthome.model.script.Judo] - 3

2018-12-15 10:56:05.139 [INFO ] [.eclipse.smarthome.model.script.Judo] - null

2018-12-15 10:56:05.159 [DEBUG] [t.http.internal.WebClientFactoryImpl] - shared http client requested

2018-12-15 10:56:05.173 [DEBUG] [lipse.smarthome.io.net.http.HttpUtil] - About to execute https://192.168.178.28:8124?group=register&amp;command=connect&amp;msgnumber=5&amp;token=null&amp;parameter=i-soft%20plus&amp;serial%20number=xxxxx

2018-12-15 10:56:05.261 [ERROR] [.smarthome.model.script.actions.HTTP] - Fatal transport error: java.util.concurrent.ExecutionException: javax.net.ssl.SSLHandshakeException: General SSLEngine problem

(Martin van Wingerden) #20

And for .org.eclipse.smarthome.model I hope we have some logging there.