Error with local http request handler


1) Give a description of the problem
Error with local http request handler, throwing an error java.lang.NullPointerException and not executing at all. I have tried different ways of formatting the URL, tried both with and without the authorization headers, I always get the same error. Unlike in a thread with a similar error message, in this case the BOND home returns a Content-Type with its return. On a successful execution using:
curl -H “BOND-TOKEN: aaabbbccc111” -i

I get back:
HTTP/1.1 200 OK
Content-Length: 18
Content-Type: application/json; charset=utf-8


2) What is the expected behaviour?
I am beta testing the BOND home API. I use several other Pistons with the “Make a web request” feature, but this one is causing trouble for some reason. What I want to have happen is an http get request to be issued to the appropriate URL and cause the BOND to transmit the correct RF single to my ceiling fan

3) What is happening/not happening?
I get an error in the trace log and it looks like no http request is made. The BOND never activates.

**4) Post a Green Snapshot of the piston![image|45x37]
Here is a screen shot of the piston. I changed the IP address, auth token, device ID, and command ID for security reasons

5) Attach logs after turning logging level to Full
8:30:50 PM: error java.lang.NullPointerException: Cannot invoke method tokenize() on null object @line 3167 (localHttpRequestHandler)
8:30:49 PM: info ╔ Event processed successfully (164ms)
8:30:49 PM: trace ║║ Requesting a wake up for Mon, May 6 2019 @ 8:31:09 PM CDT (in 20.0s)
8:30:49 PM: debug ║║ Cancelling statement #3’s schedules…
8:30:49 PM: debug ║║ Cancelling condition #1’s schedules…
8:30:49 PM: debug ║║ Cancelling condition #2’s schedules…
8:30:49 PM: debug ║║ Comparison (enum) pushed gets (string) pushed = true (1ms)
8:30:49 PM: trace ║╚ Execution stage started
8:30:49 PM: trace ║ Runtime (37622 bytes) successfully initialized in 55ms (v0.3.109.20181207) (108ms)
8:30:49 PM: debug ║ RunTime Analysis CS > 25ms > PS > 55ms > PE > 29ms > CE
8:30:49 PM: info ╚ Received event [Wyatt Bedroom Switch].button = pushed with a delay of 888ms


For local requests, I do not use:
at the beginning. Just straight IP and path.

A good way to test is to test the IP/path in a normal web browser, and once you got it working, it is easy to plug into webCoRE


Thanks for the suggestion on trying without http://. Unfortunately that changed nothing. I have many other pistons making local requests that have the http:// in their URLs, so I didn’t expect it to work but it was worth a try. As for testing in a normal browser, as I pointed out in the initial post, I know the request is valid as it works perfectly with curl. I also tested it with wget, again it works great. Using chrome I don’t have the auth token header set, but I can still send the URL and get the expected “401 Unauthorized” reply back from the API endpoint on the BOND. I use “Make a web request” quite a bit and have never encountered this error before.


Doesn’t this align with:
Cannot invoke method tokenize()

I would focus your testing using the full URL (including the token) in Chrome.
(Your current piston has no visible reference to the token)

Maybe this?


What special capability does testing in Chrome add that testing with curl and wget do not? Is WebCore using chrome code in some fashion internally?


What I mean is curl & wget are powerful, and you are sending more information in your curl that you are in your piston. The reason I am suggesting using chrome during testing is when you find a single line that works in Chrome, it should also work in webCoRE.


I was able to find the source of the “java.lang.NullPointerException: Cannot invoke method tokenize() on null object @line 3167 (localHttpRequestHandler)” error and eliminate it. I won’t go so far as to call it a webCoRE bug, but at least a GUI glitch. To recreate:
create an action using “make a web request”
for the “Send Variables” field, change “nothing selected” to “variable” and set the variable field to a value
save and run the piston
go back and edit the piston
edit the “make a web request” action
change the “Send Variables” field left column back to “nothing selected”
The variable field will automatically set itself back to “(no value set)” but it seems like webCoRE is actually holding on to the variable. Any attempt to run the piston now will throw the “java.lang.NullPointerException: Cannot invoke method tokenize() on null object”
To get rid of the error, you need to edit the “make a web request action”, change the “nothing selected” back to “variable”. The “(no value set)” will automatically go to the variable you previously selected, and the key now is to click on that, go to the top right and choose “deselect all”. Then change the “variable” back to “nothing selected”. save and re-run the piston and the error will be gone


One more follow-up on my original issue. I can’t proceed any further at this point because I cannot set the required custom header to authenticate against the BOND device. I had my fingers crossed the BOND would accept the token using the limited capability webCoRE already has, but unfortunately it will not. I will chime in on the relevant existing feature request threads for custom headers.


In the meantime, you could always send a http GET from webCoRE to one of your local machines (Raspberry, Windows, Linux etc) and let that machine send the curl. It would add a half a second to your duration, but the end results should be good if that machine is left on 24/7.


True, this is something I could try, thanks for the suggestion. The problem is, the whole reason for me wanting to use the new BOND API with webcore is to take IFTTT out of the loop and reduce apparent latency :slight_smile:
Right now, the lag from a button push on the wall in my son’s bedroom takes several seconds to get from ST out to IFTTT then on to BOND to trigger the light on the ceiling fan. Enough lag as to seriously degrade the experience. Given how slow IFTTT is, adding a local wget-to-put API “translator” will still almost certainly shave time off.


I agree with you. Even though IFTTT is quite powerful, I try to avoid using it whenever possible due to the delay in execution.


Are you sure the Authorization header does not work with the BOND API? I don’t know anything about it but noticed it used here. Maybe the local API is different or this isn’t even the same thing, but you can set an Authorization header with webCoRE if needed.


Thanks for this post … i’m having the exact same issue. Unfortunately, I dont see anywhere to "go to the top right and choose “deselect all”

I’m on a Mac running Chrome and Webcore v0.3.310