webCoRE get requests to local IP not working

I’m migrating from ST to HE and have a number of pistons which perform a get on a local ip address on the same network as the hub. These work fine on ST WC.

The get is performed on an IP e.g “Make a GET request to [192.168.0.7];”
The same pistons on HE fails to return $response, and I suspect is not even managing to make the call out.
I’ve confirmed the HE hub can ping the address. The following error is returned in the HE logs
app:682022-08-26 12:20:00.991 am debugReleased Lock and exiting
app:682022-08-26 12:20:00.988 am debugExiting
app:682022-08-26 12:20:00.945 am info ║║ $response=*
app:682022-08-26 12:20:00.878 am errorhttp Response Status: 408 error Message: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

The piston log contains the following
26/08/2022, 00:20:00 +901ms
+2ms ╔Received event [Home].wc_async_reply = httpRequest with a delay of 24ms, canQueue: false, calledMyself: true
+6ms ║RunTime initialize > 5 LockT > 0ms > r9T > 2ms > pistonT > 1ms (first state access 3 3 2)
+8ms ║Runtime (6449 bytes) initialized in 2ms (v0.3.114.20220822_HE)
+26ms ║╔Execution stage started
+34ms ║║Executed virtual command setVariable (1ms)
+38ms ║║Calculating (string)$response= + (string) >> (string)$response=
+39ms ║║Calculating (string)$response= + (string)* >> (string)$response=*
+42ms ║║$response=*
+44ms ║║Executed virtual command log (3ms)
+48ms ║║Comparison (dynamic) null is_not (string) [:] = true (1ms)
+49ms ║║Condition #6 evaluated true (3ms)
+50ms ║║Condition group #5 evaluated true (condition did not change) (5ms)
+55ms ║║Skipped execution of physical command [Start NAS-314].on([]) because it would make no change to the device. (2ms)
+56ms ║║Executed [Start NAS-314].on (2ms)
+61ms ║║Executed virtual command [Start NAS-314].setVariable (1ms)
+65ms ║╚Execution stage complete. (39ms)
+68ms ╚Event processed successfully (66ms)
26/08/2022, 00:20:00 +877ms
+3ms ╔Received event [Home].wc_async_reply = httpRequest with a delay of 0ms, canQueue: true, calledMyself: false
+5ms ╚Event queued (3ms)
26/08/2022, 00:20:00 +803ms
+4ms ╔Received event [Home].execute = :7bc150e5a57d1ea8be13be7db6ab459b: with a delay of 15ms, canQueue: true, calledMyself: false
+13ms ║RunTime initialize > 12 LockT > 1ms > r9T > 2ms > pistonT > 1ms (first state access 9 5 7)
+16ms ║Runtime (6440 bytes) initialized in 2ms (v0.3.114.20220822_HE)
+18ms ║╔Execution stage started
+26ms ║║Sending asynchttpGet web request to: 192.168.0.7
+28ms ║║Executed virtual command httpRequest (3ms)
+31ms ║║Requesting wake up at Fri, Aug 26 2022 @ 12:20:24 AM BST (in 23999ms) for 1 (st:2)
+38ms ║╚Execution stage complete. (21ms)
+64ms ║Setting up scheduled job for Fri, Aug 26 2022 @ 12:20:24 AM BST (in 24018ms)
+66ms ╚Event processed successfully (63ms)
Clear Full

Going to CC: @nh.schottfam on this one. Can you post a screen shot of the piston?

1 Like

Just tested the GET portion to a server I have running using

and got the expected response:

8/26/2022, 3:37:32 PM +73ms
+51ms	║[status:acknowledged]

So the get is working from webCoRE

This is a cut/paste of a log op posted on the webcore forum...

2022-08-25 11:05:00.873 pm errorhttp Response Status: 408 error Message: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

408 is a timeout, but the real cause could very well be an invalid certificate (or using https instead of http):

This is the piston in HE, I've used the red version so the exact get can be seen. This is identical to the working ST piston.

Apologies for posting in 2 forums, I was unclear which was most appropriate.

@gopher.ny can you comment if this error is a bad certificate, or inability of HE code to handle the certificate?

Does it work if you replace 198.162.0.7 with http://192.168.0.7 ?

I’ve tried that it fails in the same way.

app:682022-08-27 08:55:01.006 am debugReleased Lock and exiting

app:682022-08-27 08:55:01.003 am debugExiting

app:682022-08-27 08:55:00.958 am info ║║ $response=*

app:682022-08-27 08:55:00.898 am errorhttp Response Status: 408 error Message: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Not sure if it helps, but there’s a slightly different error when calling an IIS server on a windows PC (see below) the above error is from a linux os
app:702022-08-27 08:53:54.899 am errorhttp Response Status: 408 error Message: Remote host closed connection during handshake

What code produces this message?
There is a ignoreSSLIssues parameter for http calls, if set to true the call should accept all sorts of bad, self-signed, expired, etc. certificates.

1 Like

I have made a change to add the ignoreSSLIssues parameter==true

if the protocol is https and the uri contains '192.168.'

This is in latest webcore - HPM repair to try it.

1 Like

I’ve performed an HPM repair on webcore, and rebooted the hub. Changed the url to https://192.168.0.7, but still getting an error

pp:682022-08-27 02:15:01.167 pm info ║ $response=*

app:682022-08-27 02:15:01.115 pm errorhttp Response Status: 401 error Message: Unauthorized

The 401 would seem to indicate that the receiving server is expecting some type of authorization code or maybe a different path

1 Like

Are there any more options to get this to work?

A little further info, If I use a an external url to my router, and set up port forwarding on the router, the request is successful using (e.g) http://mydyndnsaddress.co.uk:1234

What that says is that webCoRE is doing it's job, i.e. sending the payload to where you tell it; the issue appears to be in how you are addressing the server - might want to take a look at the route and authorizations the port forward takes to it and see if you can match it inside the piston.

I’m not sure why it doesn’t work. The same pistons work fine on ST, although the way that works could be very different, as the get is executed on the ST hub, while the code runs in the cloud.

A few other points I’ve noticed,

  • Different errors are returned by different local targets. A windows 11 IIS closes the connection. so that would indicate routing is correct.

  • A wake on LAN piston which addresses the same devices works.

  • The HE nodeRed application connects to a rasp PI, but the get request to the same PI from webcore to a node.js target fails.

I could get the pistons to work by setting up more port forwarding rules and using my DDNS url, but I don’t really want to give external access, particularly to the NAS devices. It would also be a shame to have to ‘go external’ when one of the benefits of webcore on nubitat is that its all a local system.

you may need to post full logs and the current piston so folks can see all the data.

webcore does not try to re-write addresses, ie if you give it local it will use local. Are you using a name or an IP address? You might try to not have dns lookups involved. DNS is as HE provides it, webcore has no control on this.

This is the current piston (which works in ST). I have also tried http:// & https:// in front of the IP.

Webcore Log
31/08/2022, 14:05:01 +53ms
+3ms ╔Received event [Home].wc_async_reply = httpRequest with a delay of 1ms, canQueue: true, calledMyself: false
+11ms ║RunTime initialize > 10 LockT > 0ms > r9T > 2ms > pistonT > 0ms (first state access 8 3 7)
+13ms ║Runtime (6935 bytes) initialized in 2ms (v0.3.114.20220822_HE)
+31ms ║╔Execution stage started
+38ms ║║Executed virtual command setVariable (2ms)
+42ms ║║Calculating (string)$response= + (string) >> (string)$response=
+43ms ║║Calculating (string)$response= + (string)* >> (string)$response=*
+46ms ║║$response=*
+48ms ║║Executed virtual command log (2ms)
+51ms ║║Comparison (dynamic) null is_not (string) [:] = true (1ms)
+52ms ║║Condition #6 evaluated true (3ms)
+53ms ║║Condition group #5 evaluated true (condition did not change) (4ms)
+58ms ║║Skipped execution of physical command [Start NAS-314].on([]) because it would make no change to the device. (2ms)
+59ms ║║Executed [Start NAS-314].on (2ms)
+63ms ║║Executed virtual command [Start NAS-314].setVariable (2ms)
+67ms ║╚Execution stage complete. (37ms)
+70ms ╚Event processed successfully (68ms)
31/08/2022, 14:05:00 +807ms
+3ms ╔Received event [Home].execute = :7bc150e5a57d1ea8be13be7db6ab459b: with a delay of 19ms, canQueue: true, calledMyself: false
+47ms ║RunTime initialize > 46 LockT > 1ms > r9T > 37ms > pistonT > 35ms (first state access 8 4 42)
+49ms ║Runtime (6875 bytes) initialized in 37ms (v0.3.114.20220822_HE)
+51ms ║╔Execution stage started
+60ms ║║Sending asynchttpGet web request to: 192.168.0.7
+62ms ║║Executed virtual command httpRequest (2ms)
+64ms ║║Requesting wake up at Wed, Aug 31 2022 @ 2:05:24 PM BST (in 23999ms) for 1 (st:2)
+71ms ║╚Execution stage complete. (21ms)
+95ms ║Setting up scheduled job for Wed, Aug 31 2022 @ 2:05:24 PM BST (in 24019ms)
+97ms ╚Event processed successfully (95ms)

Hubitat Log
app:682022-08-31 02:05:01.142 pm debugReleased Lock and exiting

app:682022-08-31 02:05:01.101 pm info ║║ $response=*

app:682022-08-31 02:05:01.053 pm errorhttp Response Status: 401 error Message: Unauthorized

app:682022-08-31 02:05:00.953 pm debugReleased Lock and exiting

Can you do a curl command to that URL, and show the result?

Based on that if needed I can give you code with more debugging on to see deeper details.

Here is a simple test I have (it is an external URL), but shows the processing...

Download the Hubitat app