# Getting Error: "Parse Error: Expected HTTP" - "HPE\_INVALID\_CONSTANT"

**URL:** <https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868>\
**Category:** General\
**Created:** [18 May 2021 16:15 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868 "2021-05-18T16:15:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![NoeudRouge](https://avatars.discourse-cdn.com/v4/letter/n/13edae/32.png) [@NoeudRouge](https://discourse.nodered.org/u/NoeudRouge)\
**Post date:** [18 May 2021 16:15 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/1 "2021-05-18T16:15:16Z")

</div>

Hi,

I have a ethernet webrelay ([WebRelay | Ethernet Relay | Remote Relay Control](https://www.controlbyweb.com/webrelay/)) that opens my front door.  
To open the door I simply have to open a browser and type in:  
[http://192.168.10.224:10359/state.xml?relayState=2&pulseTime=5](http://192.168.10.224:10359/state.xml?relayState=2&pulseTime=5)  
After filling-in the credentials the door opens.

I try to do the same from node-red.  
I have 4 nodes:

- 1 injector
- 1 change node
- 1 http request node
- 1 HA node to check the status of my door.

Here is the code:

```auto
[{"id":"994311c7.7445d8","type":"inject","z":"2e0bd4f.934d72c","name":"Unlock door","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":210,"y":240,"wires":[["49d1e033.fff5f8"]]},{"id":"430d6a4c.b6affc","type":"http request","z":"2e0bd4f.934d72c","name":"Query","method":"GET","ret":"txt","paytoqs":"body","url":"","tls":"","persist":false,"proxy":"","authType":"","x":730,"y":240,"wires":[["702c1d7b.69dbd4"]]},{"id":"49d1e033.fff5f8","type":"change","z":"2e0bd4f.934d72c","name":"Prep login","rules":[{"t":"set","p":"headers.content-type","pt":"msg","to":"text/html; charset=UTF-8","tot":"str"},{"t":"set","p":"queryDate","pt":"msg","to":"$now()","tot":"jsonata"},{"t":"set","p":"headers.authorization","pt":"msg","to":"Basic ThisIsMyBase64String","tot":"str"},{"t":"set","p":"url","pt":"msg","to":"http://192.168.10.224:10359/state.xml?relayState=2&pulseTime=5","tot":"str"},{"t":"set","p":"headers.content-length","pt":"msg","to":"3495","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":240,"wires":[["430d6a4c.b6affc"]]},{"id":"702c1d7b.69dbd4","type":"api-current-state","z":"2e0bd4f.934d72c","name":"Door Open?","server":"52cfa5eb.37210c","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.alarm_contact_entree","state_type":"str","state_location":"doorOpen","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":950,"y":220,"wires":[[],[]]},{"id":"52cfa5eb.37210c","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

```

As such, the flow opens the door but I get an error and the flow stops just after the http request.

I tried unsuccessfully all sort of combinations in order to remove this error message.

Now I am stuck and would appreciate some help.

Thanks.

Sined

---

<div class="post-metadata">

**Author:** ![Ranki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ranki/32/41282_2.png) [@Ranki](https://discourse.nodered.org/u/Ranki)\
**Post date:** [18 May 2021 16:16 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/2 "2021-05-18T16:16:44Z")

</div>

Hello Sined,

Welcome to the forum! Can you please specify the error message you are receiving?

Cheers  
Ranki

---

<div class="post-metadata">

**Author:** ![NoeudRouge](https://avatars.discourse-cdn.com/v4/letter/n/13edae/32.png) [@NoeudRouge](https://discourse.nodered.org/u/NoeudRouge)\
**Post date:** [18 May 2021 16:20 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/3 "2021-05-18T16:20:44Z")

</div>

Hi Ranki,

Thank you for this rapid reaction.  
Here is the error message:

```auto
{
   "_msgid":"29ee57ca.d347c8",
   "payload":"Error: Parse Error: Expected HTTP/ : http://192.168.10.224:10359/state.xml?relayState=2&pulseTime=5",
   "topic":"",
   "headers":{
      "content-type":"text/html; charset=UTF-8",
      "authorization":"Basic MyBase64",
      "content-length":"3495"
   },
   "queryDate":"2021-05-18T16:17:32.176Z",
   "url":"http://192.168.10.224:10359/state.xml?relayState=2&pulseTime=5",
   "statusCode":"HPE_INVALID_CONSTANT"
}

```

Cheers.

Sined

---

<div class="post-metadata">

**Author:** ![Ranki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ranki/32/41282_2.png) [@Ranki](https://discourse.nodered.org/u/Ranki)\
**Post date:** [18 May 2021 16:28 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/4 "2021-05-18T16:28:28Z")

</div>

Hi Signed,

Which node is generating the error message?

Cheers  
Ranki

---

<div class="post-metadata">

**Author:** ![NoeudRouge](https://avatars.discourse-cdn.com/v4/letter/n/13edae/32.png) [@NoeudRouge](https://discourse.nodered.org/u/NoeudRouge)\
**Post date:** [18 May 2021 16:41 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/5 "2021-05-18T16:41:01Z")

</div>

The HTTP Request node

This is the change node that prepares the values for the HTTP Request Node

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/a/ca6e1633b28f8c118e8d3297f24b7310416b834e.png)

This is the HTTP Request node

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/1/912ab8aad9cac477dc5d10cc1f5940b765ebed0c.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [18 May 2021 21:59 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/6 "2021-05-18T21:59:14Z")

</div>

> [@NoeudRouge](#):
>
> After filling-in the credentials the door opens.

Have you tried entering the credentials on the http request node settings?

If that doesn't work then maybe providing the credentials in the URL will work e.g. `http://user: password@192.168.10.224:10359/state.xml?relayState=2&pulseTime=5`

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [18 May 2021 22:59 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/7 "2021-05-18T22:59:27Z")

</div>

You do not need to send payload as request body, try just ignoring the payload.

---

<div class="post-metadata">

**Author:** ![NoeudRouge](https://avatars.discourse-cdn.com/v4/letter/n/13edae/32.png) [@NoeudRouge](https://discourse.nodered.org/u/NoeudRouge)\
**Post date:** [19 May 2021 06:35 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/8 "2021-05-19T06:35:16Z")

</div>

Hi Steve,

Thank you for your reply. Yes I already tried that. No success.

Sined

---

<div class="post-metadata">

**Author:** ![NoeudRouge](https://avatars.discourse-cdn.com/v4/letter/n/13edae/32.png) [@NoeudRouge](https://discourse.nodered.org/u/NoeudRouge)\
**Post date:** [19 May 2021 06:36 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/9 "2021-05-19T06:36:10Z")

</div>

Hi E1cid,

Thank for proposing but as explained I tried almost all the combinations.

Thanks for proposing.

Sined

---

<div class="post-metadata">

**Author:** ![Ranki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ranki/32/41282_2.png) [@Ranki](https://discourse.nodered.org/u/Ranki)\
**Post date:** [19 May 2021 07:53 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/10 "2021-05-19T07:53:21Z")

</div>

Hello @NoeudRouge,

sorry, I was not at the computer anymore yesterday ... do you need all the parameters for the header etc, which you are preparing in the «prep login»-node?

Can you maybe try this one (you have to enter your credentials in the http-node and add your last node again to it; or check first the debug output):

```auto
[
    {
        "id": "994311c7.7445d8",
        "type": "inject",
        "z": "b4fa726a.49a62",
        "name": "Unlock door",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "1",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 630,
        "y": 780,
        "wires": [
            [
                "430d6a4c.b6affc"
            ]
        ]
    },
    {
        "id": "430d6a4c.b6affc",
        "type": "http request",
        "z": "b4fa726a.49a62",
        "name": "Query",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "http://192.168.10.224:10359/state.xml?relayState=2&pulseTime=5",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "basic",
        "x": 790,
        "y": 780,
        "wires": [
            [
                "d7105393.07ac7"
            ]
        ]
    },
    {
        "id": "d7105393.07ac7",
        "type": "debug",
        "z": "b4fa726a.49a62",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 930,
        "y": 780,
        "wires": []
    }
]

```

Cheers  
Ranki

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 May 2021 07:58 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/11 "2021-05-19T07:58:41Z")

</div>

> [@NoeudRouge](#):
>
> Thank you for your reply. Yes I already tried that. No success

I assume when you tried the built in authentication and the URL style authentication you removed the `authorization` header from the change node?

---

<div class="post-metadata">

**Author:** ![NoeudRouge](https://avatars.discourse-cdn.com/v4/letter/n/13edae/32.png) [@NoeudRouge](https://discourse.nodered.org/u/NoeudRouge)\
**Post date:** [19 May 2021 15:41 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/12 "2021-05-19T15:41:43Z")

</div>

Hi Steve,

Yes I removed it.

Sined

---

<div class="post-metadata">

**Author:** ![NoeudRouge](https://avatars.discourse-cdn.com/v4/letter/n/13edae/32.png) [@NoeudRouge](https://discourse.nodered.org/u/NoeudRouge)\
**Post date:** [19 May 2021 15:43 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/13 "2021-05-19T15:43:38Z")

</div>

Hello,

I tried your proposal. Door still opens but get the error message:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/f/5f6fb622f8972123ff9113520ada5b4c70a4045b.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/4/a4e5a9ad1ce0a98ea83bbb0a02c9a8dcd0ddb9a6.png)

Thanks again for your support.

Sined

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 May 2021 15:51 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/14 "2021-05-19T15:51:23Z")

</div>

If you search the forum and internet for the HPE error you will see it usually means there is something wrong with the response from the server (in your case this relay)

What do you see if you curl the URL?

Also, have you looked to see if this relay has an updated firmware or if it has a forum, raise an issue?

Lastly, does this relay have any other protocols that http API?

---

<div class="post-metadata">

**Author:** ![Ranki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ranki/32/41282_2.png) [@Ranki](https://discourse.nodered.org/u/Ranki)\
**Post date:** [19 May 2021 16:50 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/15 "2021-05-19T16:50:47Z")

</div>

Try to „play“ with the return setting; so change it from UTF-8 to the other options …

Cheers  
Ranki

---

<div class="post-metadata">

**Author:** ![Ranki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ranki/32/41282_2.png) [@Ranki](https://discourse.nodered.org/u/Ranki)\
**Post date:** [19 May 2021 16:53 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/16 "2021-05-19T16:53:06Z")

</div>

> [@Steve-Mcl](#):
>
> What do you see if you curl the URL?

… and this would be really interesting. Do you know how to use curl?

---

<div class="post-metadata">

**Author:** ![NoeudRouge](https://avatars.discourse-cdn.com/v4/letter/n/13edae/32.png) [@NoeudRouge](https://discourse.nodered.org/u/NoeudRouge)\
**Post date:** [20 May 2021 08:25 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/17 "2021-05-20T08:25:34Z")

</div>

Dear,  
Thank you for your combine effort.  
I tried with curl. The door still opens and get back the following error:

```auto
curl: (1) Received HTTP/0.9 when not allowed

```

Apparently, and I don't know if this normal, the job is sent back in the shell and the only way to recover a prompt is by doing a CTRL+C which kills the job.

Sined

---

<div class="post-metadata">

**Author:** ![NoeudRouge](https://avatars.discourse-cdn.com/v4/letter/n/13edae/32.png) [@NoeudRouge](https://discourse.nodered.org/u/NoeudRouge)\
**Post date:** [20 May 2021 08:29 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/18 "2021-05-20T08:29:41Z")

</div>

Hi,

I ran the same command with --verbose option and here is the output:

```auto
* Trying 192.168.10.224:10359...
* Connected to 192.168.10.224 (192.168.10.224) port 10359 (#0)
* Server auth using Basic with user 'admin'
> GET /state.xml?relayState=2 HTTP/1.1
> Host: 192.168.10.224:10359
> Authorization: Basic Base64Username:Password
> User-Agent: curl/7.74.0
> Accept: */*
>
* Received HTTP/0.9 when not allowed

* Closing connection 0
curl: (1) Received HTTP/0.9 when not allowed

```

---

<div class="post-metadata">

**Author:** ![NoeudRouge](https://avatars.discourse-cdn.com/v4/letter/n/13edae/32.png) [@NoeudRouge](https://discourse.nodered.org/u/NoeudRouge)\
**Post date:** [20 May 2021 09:08 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/19 "2021-05-20T09:08:40Z")

</div>

Hi,

Me again. I investigated the HTTP/0.9 protocol and apparently it could be the problem.  
By reading the [following article](https://medium.com/platform-engineer/evolution-of-http-69cfe6531ba0), it appears that:

> Blockquote

## HTTP/0.9 — The One-line Protocol

- Initial version of HTTP — a simple client-server, request-response, telenet-friendly protocol
- Request nature: single-line (method + path for requested document)
- Methods supported: `GET` only
- Response type: hypertext only
- Connection nature: terminated immediately after the response
- No HTTP headers (cannot transfer other content type files), No status/error codes, No URLs, No versioning

```auto
$> telnet ashenlive.com 80(Connection 1 Establishment - TCP Three-Way Handshake)
Connected to xxx.xxx.xxx.xxx(Request)
GET /my-page.html(Response in hypertext)
<HTML>
A very simple HTML page
</HTML>(Connection 1 Closed - TCP Teardown)

```

Popular web servers (Apache, Nginx) still supports HTTP/0/9. Try opening up a Telnet session and accessing [google.com](http://google.com)

Maybe the server behind the relay is configured with this protocol and maybe do I need to specify it in the "HTTP Request" node.

Sined

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 May 2021 09:17 UTC](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868/20 "2021-05-20T09:17:40Z")

</div>

did you explore other options?

> [@Steve-Mcl](#):
>
> Also, have you looked to see if this relay has an updated firmware or if it has a forum, raise an issue?

> [@Steve-Mcl](#):
>
> Lastly, does this relay have any other protocols that http API?

If all else fails, you could do this using the TCP nodes.

adapt [this](https://discourse.nodered.org/t/basic-fetch-error/22416/26) solution from Nick to do it raw.

[Next page](https://discourse.nodered.org/t/getting-error-parse-error-expected-http-hpe-invalid-constant/45868.md?page=2)
