Fail to execute rule ## - error

Hi all,

I have a rule that does a get-request if a specific item state is changed to on. This used to work OK but since I needed to restart OH it comes up with this error in the log:

2021-09-03 07:47:44.952 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule 'e6c6d10d7b': Fail to execute action: 4

Sometimes the rules does work and executes (I can see this by the result of the get-request that is indeed not fed back to OH). But sometimes the rule does not execute and indeed fails. Same error in both cases. Does anybody has a clue please? Logs, as you can see, are pretty minimal.
Rule itself:

  - id: "1"
      itemName: network_TF_keuken
      state: ON
    type: core.ItemStateChangeTrigger
  - id: "2"
      itemName: network_TF_sk4
      state: ON
    type: core.ItemStateChangeTrigger
  - id: "3"
      itemName: network_TF_woonkamer
      state: ON
    type: core.ItemStateChangeTrigger
conditions: []
  - inputs: {}
    id: "4"
      type: application/javascript
      script: >-
        var logger =


        var HttpUtil = Java.type("");

        var tf = event.itemName.split('_')[event.itemName.split('_').length - 1];"var tf = " + tf);

        HttpUtil.executeUrl("GET", "" + tf, 1);
    type: script.ScriptAction

So add some more so you can determine which line in that rule it is failing on. Is there a reason you are not using sendHttpGetRequest?

I found my way via google. The sendHttpGetRequest wasn’t working for me but that is most likely due to my coding skills.

I’ll add more info-log-lines but up until I set var tf this rule looks the same as others so it can’t be going wrong in many ways :wink:


var logger =

"Part 1");

        var HttpUtil = Java.type("");"Part 2");

        var tf = event.itemName.split('_')[event.itemName.split('_').length - 1];"Part 3");"var tf = " + tf);"Part 4");

        HttpUtil.executeUrl("GET", "" + tf, 1);"Part 5");


2021-09-03 22:34:09.624 [INFO ] [g.openhab.model.script.Rules.Network] - Part 1

2021-09-03 22:34:09.631 [INFO ] [g.openhab.model.script.Rules.Network] - Part 2

2021-09-03 22:34:09.644 [INFO ] [g.openhab.model.script.Rules.Network] - Part 3

2021-09-03 22:34:09.646 [INFO ] [g.openhab.model.script.Rules.Network] - var tf = sk4

2021-09-03 22:34:09.647 [INFO ] [g.openhab.model.script.Rules.Network] - Part 4

2021-09-03 22:34:09.655 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule 'e6c6d10d7b': Fail to execute action: 4

So it fails at HttpUtil.executeUrl("GET", "" + tf, 1); but the request does get sent…

It was this topic where I got my script from.

It might tell you why if you listen to it

var results = HttpUtil.executeUrl("GET", "http ..."results " + results);

Your timeout doesn’t seem very generous, 1mS?

Thanks for the hint. Hope with the increase in timeout it will get past your suggested approach because now it does not execute anything after that specific line.

I do/did not need the result, just the command send to the other device so I thought ‘why wait for something I don’t want the reply from?’

We’ll see :slight_smile:

Unfortunately it doesn’t. It stops executing at the same line, although that line is now preceded by var results = .

Worth a try. Maybe if you use the sendHttpGetRequest() Action provided for use in rules, as hinted before, it might be more forthcoming.

javascript usage example

It is and works. So all of you thanks for the tips. I do wonder though why that other script did fail. Or sort of failed. The http-get-request was sent but then it still produced an error.