OH3 + HTTP2 binding error

Anyone know why I get this error using the OH3 (v3.0.1) + HTTP2 binding? Thanks for your help.

Thing http:url:wanip "WanIP" [ 
	baseURL="https://api.ipify.org",
    timeout=3000,
	refresh=5
    ] {
		Channels:
			Type string : wanip "my wan ip" [ 
                stateTransformation="JSONPATH:$.ip", 
                stateExtension="?format=json" ]
}


2021-03-02 20:17:20.380 [WARN ] [p.internal.http.HttpResponseListener] - Requesting 'https://api.ipify.org/?format=json' (method='GET', content='null') failed: Total timeout 3000 ms elapsed

As a workaround I tried to use REGEX and get the same error

Thing http:url:wanip "WanIP" [ 
	baseURL="https://api.ipify.org",
    timeout=3000,
	refresh=5
    ] {
		Channels:
			Type string : wanip "my wan ip" [ 
                stateTransformation="REGEX:(.*)" ]
}

the related transformations are installed ?

JSONPATH is for sure I use it everywhere for my MQTT binding.
oops REGEX was not. (I corrected my original post so it’s not confusing in the future)

Still unclear why the JSON call fails.

I don‘t think it‘s related to the transformation. The timeout occurs during the HTTP request.

I changed it to use JS transformation and it works. :confused:

There is still a weird bug somewhere with the previous examples and it is not the site being queried because it works just fine when using JS transformation (and from a browser).

Thing http:url:ip "WanIP" [ 
	baseURL="https://api.ipify.org",
    timeout=3000,
	refresh=60
    ] {
		Channels:
			Type string : wanip "my wan ip" [ 
                stateTransformation="JS:wan_ip.js",
                stateExtension="?format=json" ]
}

Might be related to the use of .things files. If you search the forum there are a lot of reports of things not loaded at all or not properly disposed if things-files are edited. I recommend using managed things via UI.

If you encounter the issue again you could increase the binding log level to TRACE and see what exactly is send and received.

How does one increase the binding log level to TRACE in OH3?

The easiest way is to log into the Karaf console and issue the command to change the org.openhab.binding.HTTP (or something like that, you shoudl be able to see in your current logs the name of the logger, it’s in the [ ] after the logging level).

Alternatively you can add a line to the /var/lib/openhab/etc/log4j2.xml to set the logging level for that binding.

2 Likes

Could you share your “wan_ip.js” script code?
I’ve been struggling with HTTP binding on my OH3 for a few days now, it seems I’ve already checked every possible combination and I keep getting a message like
this
Requesting ‘https://123.123.123.123?something’ (method=‘GET’, content=‘null’) failed: Total timeout 3000 ms elapsed

I thought that since you had problems but you solved them and you have a working configuration, I’ll use it at home and check if it works.

If works I’ll know that the code I’m still checking needs tweaking, but if your setup doesn’t work I’ll know it’s some setting issue within OH3 or maybe RPi4.
I will be grateful for your help. I found some related topics but us understood binding has changed for OH3 so they are no more essential for my case.