Hpe_invalid constant

Hi - Newbie here. ( Go Easy :wink:

I have a device which runs a web browser ( ESP8266 ) with sensors collecting electricity values. The device runs a basic http Query API which can be triggered via browser and the payload is either Json or CSV.

In my very basic first attempt with Node-Red i have started with an "Inject node" ( because i cannot figure out how to run a http node without "inject" - anyway Node flow for test is "Inject / HTTP Request / Debug " ( see screenshot ).

I have tried various options within the "HTTP Request" node but keep getting "HPE_INVALID CONSTANT". I cannot continue - any help please ??

By the way the HTTP string works fine from Browser level:-
http://41.192.149.206:8080/query?select=[time.iso,ch1.d2,ch1.amps.d2,ch1.va.d2,ch1.pf.d2,ch2.d2,ch2.amps.d2,ch2.va.d2,ch2.pf.d2,ch3.d2,ch3.amps.d2,ch3.va.d2,ch3.pf.d2,ch4.d2,ch4.amps.d2,ch4.va.d2,ch4.pf.d2,ch5.d2,ch5.amps.d2,ch5.va.d2,ch5.pf.d2,ch6.d2,ch6.amps.d2,ch6.va.d2,ch6.pf.d2,ch7.d2,ch7.amps.d2,ch7.va.d2,ch7.pf.d2,ch8.d2,ch8.amps.d2,ch8.va.d2,ch8.pf.d2,ch9.d2,ch9.amps.d2,ch9.va.d2,ch9.pf.d2,ch10.d2,ch10.amps.d2,ch10.va.d2,ch10.pf.d2,ch11.d2,ch11.amps.d2,ch11.va.d2,ch11.pf.d2,ch12.d2,ch12.amps.d2,ch12.va.d2,ch12.pf.d2]&begin=h-30m&end=h&group=30m&format=json&header=yes

A quick Google search for the hpe error gives the answer:

In summary, your device web server is using an old version of http that node.js doesn't support.

I saw that post on stack - i ran Curl -I with the URL in Terminal and response code is HTTP /1.1

Not sure that is my problem? What do you think @knolleary is there anything else you can think i try?

Is the server setting the content-length correctly ?

Not sure what that means - or how to check ? Query works in browser ( if that helps )

@knolleary @dceejay - I tried the same Query with Thingsboard "rest API call" now and dont get any errors. So i am hoping its something small that i am overlooking in NR?

Any ideas community?

Well it means that there is something wrong with the response from the server - normally it means the header is incorrect. I see that it does include a length (108267 bytes) - is the response exactly that long ?

this is the length of the response from just the url , which serves up a html page. I just posted this result to see that the http was infact 1.1 to exclude Nicks theory.

In my query i can set Header=yes / no , either give the "HPE invalid constant".

Is there perhaps a different node i could try to troubleshoot or approach from a different angle?

The http-request node uses the NodeJS request module.
If you have some basic NodeJS skills, you could use a small test script and track down the error outside of Node-RED first.

Good starting point would be the example from the docs.

Just do the following:

  1. create a new directory and change into it
  2. run npm install request
  3. create a JS file with the code from the example
  4. run it with node myfile.js

I dont ;-( but i will try . Thank You

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.