New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RequestError: Parse Error: Missing expected CR after header value #3772
Comments
Nothing should have changed in the http-request node between 2.2.2 and 3.0.0. It's still using the same got library to make HTTP requests. What has changed is the image tagged with What is the device you are making the request to? I assume it's a network camera? Are you sure the device is following the spec and inserting the required crlf after the headers and before the payload? |
Also, your flow IS sending a payload (or at least the |
Changed from I am using https://github.com/Thom-x/rtsp-snapshot to take snapshots of a security camera, maybe the HTTP implementation is not following the spec, but it works in node-red v2.2.2. |
It is not, because I am ignoring the payload on the HTTP request node. |
Can you try and capture the request (with something like wireshark) please. Having had a quick look at the rtsp-snapshot cgi it will end up being 2 requests
It would be useful to know if it's the first or second request it's failing on |
This is the capture:
|
I've set this up locally and it's running fine with NodeJS 16.15.0 Will try with the docker image |
Fails with Docker image on NodeJS 16.16 |
As of NodeJS 16.16.x Nodejs rejects HTTP responses that do not meet the spec This patch makes the head compliant by ending lines with CRLF See for details: node-red/node-red#3772
Pull request to fix the rtsp container you are using: |
Still need to look at if GOT can be made to accept none compliant headers, but based on experience with that team I expect them to say fix the broken server (which we have tried to do) |
That is the best response, but I think that we should have a feature on the HTTP request node to add options like insecureHTTPParser to overcome this issues. |
The problem is that the http-request node uses the GOT library under the covers, if they won't add support there is not much we can do (we changed the http-request node to use GOT from request in 2.2.0, we can't change it again, and really don't want to, until the next minor release 3.1.x) |
As expected:
|
The fix to Thom-x/rtsp-snapshot#2 has been merged, hopefully they will push a new version to docker hub or you can every easily build it yourself. |
I've asked GOT nicely to reconsider, but not hopeful |
GOT not going to implement this, but suggest we can inject with own https://github.com/apify/got-scraping/blob/master/src/hooks/insecure-parser.ts |
potential fix for node-red#3772
Same issue to me capturing a camera snapshot after the upgrade to v3.0. I use the "http request" node |
@alexbn71 Just to be 100% clear, if you are using the rtsp-snapshot container that has been fixed, you will probably need to pull the latest version from github as I don't think the author has pushed the update to docker hub yet (feel free to ask them nicely) If you are using something else, then what ever it is is broken and in breach of the HTTP spec, so you are lucky anything works with it. There is a PR for Node-RED that will allow a broken headers to be accepted, but it will probably take a few iterations before it's merged, if you are happy to build Node-RED from src then it's here #3776, otherwise you will have to wait, |
For me, your fix solved the issue. |
@fvillena Please be clear (since I provided both fixes), do you mean the rtsp-snapshot PR or the Node-RED PR? |
Sorry, Thom-x/rtsp-snapshot#2 fixed my issue |
FYI: I'm also hitting the "RequestError: Parse Error: Missing expected CR after header value" issue. This is with a 2009 device controlling my veggie garden watering. |
I am also getting the error in this Node RED flow on an Hyper-V Home Assistant installation. I am quite sure the issue has the same root cause as this one. I installed the KB5015814 yesterday (again) and since then this flow cannot read any data from my Grünbeck water sofenting system anymore and produces this error messages. I experienced the same behaviour 10 days ago, when the KB was installed autmatically the first time. After uninstalling the KB back then in order to get my shellys up and running, my node red flow pulled the data from the water softening system as well again. Please forgive me for not adding more technical details - I do not rellay understand what is happening there and therefore can only provide my observations. |
@knolleary I have reviewed the attached PR and discussed with @hardillb While I realise this PR is marked as an enhancement, due to recent nodejs changes, (where it introduced stricter header separator parsing because of GHSA-q5vx-44v4-gch4) some flows will break when users update nodejs (for the upgrade to NR v3.x) - perhaps we might want to consider this for the next minor release - OR - pull forward on 3.1.0? |
@Steve-Mcl / @knolleary The "enhancement" tag was mine, probably a mistake. My take is this is a fix for the upstream NodeJS change, and GOT are not going to fix it. It should probably go into the next 2.2.x service release as well since this will hit anybody running on the latest 14.x/16.x/18.x NodeJS release to access "broken" http servers. |
potential fix for node-red#3772
Hi i have same problem with latest verison from today (3.0.2: Maintenance Release) i see the " Disable strict HTTP parsing". i just try to shutdown my picoreplayer with easy GET -> http://192.168.23.20/cgi-bin/main.cgi?ACTION=shutdown but is not working anymore :( should it be fixed already? "RequestError: Parse Error: Missing expected CR after header value" |
"Disable strict HTTP parsing" doesn't resolve the issue to me. |
I will have another look But @alexk111 & @FISEChris1337 it is important to remember that it the HTTP server you are trying to connect to that is broken here and not conforming to the HTTP spec. You need to raise issues against who ever owns them pointing out that it will be broken with ALL currently supported NodeJS versions going forward by default. |
Yes @hardillb I know this. But in my case it's an IP Cam and I have no chance to resolve the issue on that side. Also it always worked with nodered 2.x and therefore I would like to have it working again... it's a small hope that it will still work in the future. |
Add the following at line 89 in the http-request.js file
|
I've hit this error also with pCP and calling some scripts from Node-RED. Luckily I was making my own cgi scripts so could just implement the fix, but I've posted it below so hopefully someone will sort it in the main project files. Appreciate this is specific to one service and not the wider discussion around strict HTTP parsing, but as someone had explicitly noted pCP I thought I'd comment. Thanks! |
Current Behavior
When doing a simple GET request with no payload to an endpoint that should return a binary buffer (an image) I get the following error:
RequestError: Parse Error: Missing expected CR after header value
The node was working before version 3. Maybe it is related to nodejs/node#43798
Expected Behavior
Return a binary buffer.
Steps To Reproduce
This is the node:
Example flow
Environment
The text was updated successfully, but these errors were encountered: