[Solved] HTTP binding post problem

Dear all,

first of all Happy New Year to all of you in the OH world and thanks for your never ending support!

Now to my problem…
I am on openHAB 2.5.0-1 (Release Build)

I have created an HTTP item in /items/http.items via the command:
Switch Leselampe “Leselampe” (gEG_Wohnzimmer,gHaus) [ “Switchable”] { http=">[ON:POST:http://192.168.229.37/control?cmd=event,s20_2_on] >[OFF:POST:http://192.168.229.37/control?cmd=event,s20_2_off]" }

It works fine when using google chrome and just posting the event directly to the device.
But when I try to activate (push) that switch via OH, it does not work at all.
I have tried it via the REST API and also via normal switch which I have created in the sitemap:

[start Muldeweg.sitemap]
sitemap Muldeweg label=“Muldeweg” {

Frame label="Lichtsteuerung" {
        Default item=Leselampe label="Leselampe" 
} // END Frame Lichtsteuerung

} // END Sitemap Muldeweg

[end Muldeweg.sitemap]

I get this in /var/log/openhab2/events.log when activating the switch:
2020-01-02 09:09:50.701 [ome.event.ItemCommandEvent] - Item ‘Leselampe’ received command ON

I am not able to determine the root cause.
I have had it already working until I have upgraded from openHAB 2.5.0~S1660-1 to my current release.

From time to time I keep getting this error in the log, but I am not able to link this one to my actual problem (/var/log/openhab2/openhab.log):
2020-01-02 08:59:22.490 [ERROR] [org.openhab.io.net.http.HttpUtil ] - Fatal transport error: java.net.ConnectException: Connection timed out (Connection timed out)

Perhaps somebody of you is able to help and to give me some advice how to analyse further.

Many thanks in advance!

BR
Lars

This the http v1 binding
You need to enable legacy bindings in the paperUI and then install the v1 binding

Hi vzorglub,

Thanks for your quick response.
This has already been activated.
I am using http binding 1 1.14.

What else could I check?

BR
Lars

Your http.cfg file, please

[Beginn of http.cfg:]

timeout in milliseconds for the http requests (optional, defaults to 5000)

#timeout=

the interval in milliseconds when to find new refresh candidates

(optional, defaults to 1000)

#granularity=

whether to substitute the current time or state value into the URL

(optional, defaults to true)

#format=

configuration of the first cache item

#.url=
#.updateInterval=

configuration of the second cache item

#.url=
#.updateInterval=
[end of http.cfg]

Thanks for your help.

BR
Lars

Increase the timeout, see what happens

Hi all,

I have chaged the timeout to 50000.
But it has not changed anything.

When switching the item I get:
2020-01-08 07:37:37.199 [ome.event.ItemCommandEvent] - Item ‘Leselampe’ received command ON

2020-01-08 07:37:52.301 [ome.event.ItemCommandEvent] - Item ‘Leselampe’ received command OFF

But nothing is happening on the device.

Is there any way to test the http command directly from the karaf console?
(http://192.168.229.37/control?cmd=event,s20_2_on)

BR
Lars

Hi,

I have created an own log for the http binding and found only the following entries:

[08:32:10] openhabian@openHABianPi:/var/log/openhab2$ cat http.log | grep Exec
08-Jan-2020 08:21:18.582 [DEBUG] [org.openhab.binding.http.internal.HttpBinding ] - Executing url ‘http://192.168.229.37/control?cmd=event,s20_2_off’ via method POST
08-Jan-2020 08:30:11.521 [DEBUG] [org.openhab.binding.http.internal.HttpBinding ] - Executing url ‘http://192.168.229.37/control?cmd=event,s20_2_on’ via method POST

No additional suspicious entries around.
Would anybody have some ideas how to further analyse this problem?
Is there a way to log the result of the executiion of the POST command?

BR
Lars

The binding doesn’t do anything with the result. If I get time later, I could add some additional debug output to let you see it.

You could also probably get a peek at the wire traffic by setting the log level to TRACE for these packages:

  • org.openhab.io.net.http
  • org.openhab.binding.http

Fair warning: this will generate a LOT of output.

Hi,

many thanks for your help.

The root cause of my problem has been a freeze on one of my network devices.
Reboot has solved the problem.

thanks

BR
Lars