Web request error: "Error executing external web request: groovyx.net.http.ResponseParseException: OK"


#1

1) Give a description of the problem
A ‘web request’ GET errors instead of returning the expected data.
A request via a browser works fine using the same url: http://www.emoncms.org/feed/value.json?id=97715. The response in a browser is: “SOME_VALUE_HERE”.
I have tried both JSON and FORM type requests.
I have another get request to another site running fine, but that site is returning formatted json not a value in “”".

2) What is the expected behavior?
The web request would place the above data in $response.

3) What is happening/not happening?
Log shows an error: “Error executing external web request: groovyx.net.http.ResponseParseException: OK”

4) Post a Green Snapshot of the pistonimage

Note that the green snapshot has altered the URL I was using - the real url is given above.

5) Attach any logs (From ST IDE and by turning logging level to Full)
|+0ms|╔Received event [Home].time = 1519575387152 with a delay of -997ms|
|—|---|
|+95ms|║RunTime Analysis CS > 17ms > PS > 55ms > PE > 23ms > CE|
|+97ms|║Runtime (37033 bytes) successfully initialized in 55ms (v0.2.102.20180116) (95ms)|
|+98ms|║╔Execution stage started|
|+107ms|║║Cancelling statement #2’s schedules…|
|+113ms|║║Sending external web request to: www.emoncms.org/feed/value.json?id=97715|
|+277ms|║║Error executing external web request: groovyx.net.http.ResponseParseException: OK|
|+278ms|║║Executed virtual command httpRequest (166ms)|
|+281ms|║║Executed virtual command setVariable (1ms)|
|+284ms|║╚Execution stage complete. (187ms)|
|+285ms|║Setting up scheduled job for Sun, Feb 25 2018 @ 4:17:27 PM GMT (in 60.712s)|
|+291ms|╚Event processed successfully (291ms)|


Tesla API Access
#2

I’m guessing it’s erroring out because it’s simply returning “385.05376344086”.
For example, if I change the URL to just www.emoncms.org/feed/value.json, I get the following response:
{“success”:false,“message”:“Feed does not exist”}

When I do a Log $response to console, it shows up properly.

2/26/2018, 8:36:43 AM +114ms
+0ms ╔Received event [Home].test = 1519652203113 with a delay of 1ms
+65ms ║RunTime Analysis CS > 11ms > PS > 30ms > PE > 24ms > CE
+67ms ║Runtime (36551 bytes) successfully initialized in 30ms (v0.3.000.20180224) (66ms)
+69ms ║╔Execution stage started
+74ms ║║Cancelling statement #1’s schedules…
+80ms ║║Sending external web request to: www.emoncms.org/feed/value.json
+256ms ║║Executed virtual command httpRequest (176ms)
+263ms ║║[message:Feed does not exist, success:false]
+266ms ║║Executed virtual command log (3ms)
+270ms ║╚Execution stage complete. (200ms)
+271ms ╚Event processed successfully (271ms)

I’ll play around with it and try to figure something out, I can certainly see value in finding a solution for this.


#3

I tried calling this URL in webcore 50 different ways with the same result and I honestly have no clue why it errors out. Seems like it should be simple, maybe somebody with more experience will chime in.

Using curl, it looks simple enough:

Trying 80.243.190.58…
TCP_NODELAY set
Connected to www.emoncms.org (80.243.190.58) port 80 (#0)
GET /feed/value.json?id=97715 HTTP/1.1
Host: www.emoncms.org
User-Agent: curl/7.52.1
Accept: /
HTTP/1.1 200 OK
Date: Mon, 26 Feb 2018 14:34:48 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.25
Set-Cookie: PHPSESSID=1stprbrdl700nouhtk9v6jpm84; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-c
Pragma: no-cache
Content-Length: 17
Connection: close
Content-Type: application/json
Curl_http_done: called premature == 0
Closing connection 0
"394.83870967742"


#4

Thanks for your help allrak.

Does anyone have a suggestion how to work round this for the moment?
Thank you!


#5

I saw a similar error recently, for some reason when a response is declared as JSON (by the responding server, not by your piston) groovy’s web request library expects it to be an {...} object or [...] array. The response to your request is perfectly valid JSON it’s just not an object or array but the groovy language is incapable of handling it.

I did some debugging in the code here and unfortunately there seems to be no opportunity to fix this on our end. The exception includes information about the response but SmartThings blocks the ability to get the raw content as well as the ability to build a new response with a different content type like plain text. It seems there is quite literally nothing that we can do here with the tools that SmartThings provides.


#6

Okay, thanks for checking Ian!

If anyone has an idea how to get that data manipulated outside webCore so webCore can pull it back, please let me know. I’ll look into that now.


#7

You could work around it if you have a separate web server. When I was testing this, I created a “test.txt” (which simply contained the results of your URL) file on my apache server. Then I made the webcore web request for that file (test.txt) and it does indeed return the data to webcore (my server isn’t responding in json).

Then you could create a cron job and have curl call the URL and dump the results to the file every X hours or minutes.

It works, but I really don’t know your capabilities and whether or not you have your own server running somehwere.


#8

I’m trying to avoid having to run a web-server - one more thing to maintain.
However I’m also currently looking at Blue Iris, so might have to bite the bullet with a server now anyway.

Thanks!


#9

I have an AWS linux server I run. You can sign up for free and launch a small EC2 instance in the cloud (free-tier). Very low maintenance - Every month or so I login and update the software.
Costs me zero dollars per month. Also nice to have because I send a lot of my ST data there and graph it using influxDB and Grafana.
Anyhow, just a thought!


#10

Yeh good idea. I also need to think about what to do with data being generated in webCoRE and something like that might be the best long term option for several things. A Blue Iris cloud solution would be ideal as well.