Incorrect webrequest responses


#1

1) Give a description of the problem
I’m trying to loop over a list of network devices, and if a device is offline perform an action. The problem is that httpStatusOK is saying devices are offline when they are, and vice versa.

2) What is the expected behavior?
To accurately determine if an HTTP request was successful when sending requests asynchronously. The goal is to be able to resend requests that fail.

3) What is happening/not happening?
In my example piston below, devices 192.168.0.151, and 192.168.0.105 are ONLINE, and 192.168.0.152 is OFFLINE. It’s saying that my device 192.168.0.152 is online when it is in fact turned off. Device 192.168.0.105 is in fact receiving messages despite my logs saying it’s offline.

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full

Logging Level: None (My Logs)

12/4/2020, 5:04:59 PM +78ms
+91ms ║Panel: 192.168.0.105 Status: ERROR
12/4/2020, 5:04:41 PM +431ms
+66ms ║Panel: 192.168.0.152 Status: OK
12/4/2020, 5:04:40 PM +50ms
+58ms ║Panel: 192.168.0.151 Status: OK

Logging Level: Full

+0ms ╔Received event [Home].time = 1607130125986 with a delay of -828ms
+39ms ║RunTime Analysis CS > 18ms > PS > 5ms > PE > 17ms > CE
+42ms ║Runtime (39662 bytes) successfully initialized in 5ms (v0.3.110.20191009) (41ms)
+43ms ║╔Execution stage started
+56ms ║║Calculating (integer) 3 - (integer) 1 >> (integer) 2
+74ms ║║Calculating (string) Panel: + (string) 192.168.0.105 >> (string) Panel: 192.168.0.105
+77ms ║║Calculating (string) Panel: 192.168.0.105 + (string) Status: >> (string) Panel: 192.168.0.105 Status:
+80ms ║║Calculating (string) Panel: 192.168.0.105 Status: + (string) ERROR >> (string) Panel: 192.168.0.105 Status: ERROR
+84ms ║║Panel: 192.168.0.105 Status: ERROR
+85ms ║║Executed virtual command log (2ms)
+88ms ║╚Execution stage complete. (44ms)
+89ms ╚Event processed successfully (89ms)
12/4/2020, 5:01:50 PM +293ms
+1ms ╔Received event [Home].wc_async_reply = httpRequest with a delay of 0ms
+41ms ║RunTime Analysis CS > 17ms > PS > 7ms > PE > 17ms > CE
+43ms ║Runtime (39667 bytes) successfully initialized in 7ms (v0.3.110.20191009) (41ms)
+44ms ║╔Execution stage started
+54ms ║║Calculating (integer) 3 - (integer) 1 >> (integer) 2
+69ms ║║Calculating (string) Panel: + (string) 192.168.0.152 >> (string) Panel: 192.168.0.152
+72ms ║║Calculating (string) Panel: 192.168.0.152 + (string) Status: >> (string) Panel: 192.168.0.152 Status:
+74ms ║║Calculating (string) Panel: 192.168.0.152 Status: + (string) OK >> (string) Panel: 192.168.0.152 Status: OK
+77ms ║║Panel: 192.168.0.152 Status: OK
+78ms ║║Executed virtual command log (1ms)
+80ms ║╚Execution stage complete. (36ms)
+81ms ║Setting up scheduled job for Fri, Dec 4 2020 @ 5:02:05 PM PST (in 15.612s)
+96ms ╚Event processed successfully (96ms)
12/4/2020, 5:01:46 PM +338ms
+1ms ╔Received event [Home].wc_async_reply = httpRequest with a delay of 0ms
+43ms ║RunTime Analysis CS > 22ms > PS > 6ms > PE > 15ms > CE
+46ms ║Runtime (39667 bytes) successfully initialized in 6ms (v0.3.110.20191009) (44ms)
+47ms ║╔Execution stage started
+58ms ║║Calculating (integer) 3 - (integer) 1 >> (integer) 2
+73ms ║║Calculating (string) Panel: + (string) 192.168.0.151 >> (string) Panel: 192.168.0.151
+76ms ║║Calculating (string) Panel: 192.168.0.151 + (string) Status: >> (string) Panel: 192.168.0.151 Status:
+79ms ║║Calculating (string) Panel: 192.168.0.151 Status: + (string) OK >> (string) Panel: 192.168.0.151 Status: OK
+84ms ║║Panel: 192.168.0.151 Status: OK
+85ms ║║Executed virtual command log (2ms)
+87ms ║╚Execution stage complete. (40ms)
+89ms ║Setting up scheduled job for Fri, Dec 4 2020 @ 5:02:05 PM PST (in 19.519s), with 1 more job pending
+100ms ╚Event processed successfully (100ms)
12/4/2020, 5:01:45 PM +815ms
+0ms ╔Received event [Home].test = 1607130105814 with a delay of 0ms
+33ms ║RunTime Analysis CS > 18ms > PS > 6ms > PE > 10ms > CE
+36ms ║Runtime (39659 bytes) successfully initialized in 6ms (v0.3.110.20191009) (35ms)
+38ms ║╔Execution stage started
+51ms ║║Calculating (integer) 3 - (integer) 1 >> (integer) 2
+56ms ║║Cancelling statement #207’s schedules…
+66ms ║║Calculating (string) http:// + (string) 192.168.0.151 >> (string) http://192.168.0.151
+70ms ║║Calculating (string) http://192.168.0.151 + (string) :1817/?message=DATA >> (string) http://192.168.0.151:1817/?message=DATA
+77ms ║║Sending internal web request to: 192.168.0.151:1817/?message=DATA
+80ms ║║Executed virtual command httpRequest (4ms)
+82ms ║║Requesting a wake up for Fri, Dec 4 2020 @ 5:02:05 PM PST (in 20.0s)
+100ms ║║Calculating (integer) 3 - (integer) 1 >> (integer) 2
+104ms ║║Cancelling statement #207’s schedules…
+115ms ║║Calculating (string) http:// + (string) 192.168.0.152 >> (string) http://192.168.0.152
+118ms ║║Calculating (string) http://192.168.0.152 + (string) :1817/?message=DATA >> (string) http://192.168.0.152:1817/?message=DATA
+125ms ║║Sending internal web request to: 192.168.0.152:1817/?message=DATA
+128ms ║║Executed virtual command httpRequest (3ms)
+129ms ║║Requesting a wake up for Fri, Dec 4 2020 @ 5:02:05 PM PST (in 20.0s)
+140ms ║║Calculating (integer) 3 - (integer) 1 >> (integer) 2
+145ms ║║Cancelling statement #207’s schedules…
+155ms ║║Calculating (string) http:// + (string) 192.168.0.105 >> (string) http://192.168.0.105
+159ms ║║Calculating (string) http://192.168.0.105 + (string) :1817/?message=DATA >> (string) http://192.168.0.105:1817/?message=DATA
+166ms ║║Sending internal web request to: 192.168.0.105:1817/?message=DATA
+168ms ║║Executed virtual command httpRequest (3ms)
+170ms ║║Requesting a wake up for Fri, Dec 4 2020 @ 5:02:05 PM PST (in 20.0s)
+183ms ║╚Execution stage complete. (146ms)
+193ms ║Setting up scheduled job for Fri, Dec 4 2020 @ 5:02:05 PM PST (in 19.891s), with 2 more jobs pending
+234ms ╚Event processed successfully (234ms)


#2

I would try at least a 12 second WAIT inside your loop.
(web requests do not make for good spam)


#3

My devices have been receiving the requests very reliably, it’s very rare they don’t receive them with the setup I have above. However, in the rare chance one fails I was hoping to use $httpStatusOk to determine if it failed and resend it.

The only problem I’m having is it seems $httpStatusOk is reporting back out of order. Is there anyway to achieve this? The devices all need to be turned on at the same time so waits are not an option.


#4

Can you show full logs?


#5

They’re included in my original post under 5. Have to hit the little arrow drop-down to show them.


#6

Try looking at the value of $response, I use this to check my NAS is running. If everthing is ok it returns “:”, otherwise the error message


#7

I was actually able to resolve this by breaking each device into it’s own piston, so now my primary piston calls all 3 pistons turning on my devices. I notice no added delays doing it this way. Now I can easily track and log specific details for each device and retry sending the data when it fails.

Not sure if having multiple pistons firing off at once is a bad thing or not but it seems to be working well as of now. My individual device pistons look like this for those interested.