Getting HPE_UNEXPECTED_CONTENT_LENGTH error when trying to consume ElasticSearch from NodeJS
I'm trying to access ElasticSearch 5.3 with NodeJS 7.10 (using the axios library) and I'm getting this error: HPE_UNEXPECTED_CONTENT_LENGTH
Comments (5)
-
Account Deactivated -
Sure, using the standard http node library, I get this:
req = http.request('http://localhost:4571/_nodes'); req.on('error', console.error); req.end(); { Error: Parse Error at Socket.socketOnData (_http_client.js:411:20) at emitOne (events.js:96:13) at Socket.emit (events.js:191:7) at readableAddChunk (_stream_readable.js:178:18) at Socket.Readable.push (_stream_readable.js:136:10) at TCP.onread (net.js:561:20) bytesParsed: 35, code: 'HPE_UNEXPECTED_CONTENT_LENGTH' }
I figured out the problem using curl:
curl -i http://localhost:4571/_nodes HTTP/1.0 200 OK Server: BaseHTTP/0.3 Python/2.7.13 Date: Wed, 05 Jul 2017 14:30:00 GMT content-type: application/json; charset=UTF-8 content-length: 5368 Content-Length: 5368
The
Content-Length
header is included twice in the response and that's what's messing up the NodeJS HTTP parser. -
Account Deactivated Good catch, thanks for debugging this issue @demetriusnunes . This is fixed in commit ee8832161e954128d11f96edd96968e57b0782c7 . The Docker image (tags
0.6.0
andlatest
) is currently being built and pushed, it should be available soon: https://bitbucket.org/atlassian/localstack/addon/pipelines/home#!/results/%7B20edd65e-ad13-4296-93e3-d61e30a3dace%7DClosing this issue, please re-open if the problem persists. Thanks
-
Account Deactivated - changed status to resolved
-
Thank you!
- Log in to comment
Hi, thanks for reporting. Would you be able to provide a minimal test case / working example to reproduce the issue? Thanks.