fullscale / elastic.js

A JavaScript implementation of the elasticsearch Query DSL
http://docs.fullscale.co/elasticjs/
MIT License
654 stars 163 forks source link

411 status error code #16

Closed pulkitsinghal closed 11 years ago

pulkitsinghal commented 11 years ago

Have the authors of elastic.js ever run into the scenario where a 411 status code is returned while posting data with this client?

<html>
<head><title>411 Length Required</title></head>
<body bgcolor="white">
<center><h1>411 Length Required</h1></center>
<hr><center>nginx/1.1.19</center>
</body>
</html>

Its understandable that the client isn't ready for this and the JSON.parse() method in elastic-node-client.js:208:25 gets confused and the system throws a SyntaxError:

undefined:1
<html>
^
SyntaxError: Unexpected token <
    at Object.parse (native)
    at IncomingMessage.ejs.NodeClient.put (./node_modules/elastic.js/elastic-node-client.js:208:25)

But I'm more curious as to why the client might run into such a situation in the 1st place.

pulkitsinghal commented 11 years ago

Found a clue so wanted to share: 1) https://github.com/elasticsearch/cookbook-elasticsearch/issues/38 2) And another client with a similar problem: https://github.com/phillro/node-elasticsearch-client/issues/64 ... attempts (but fails I think) to solve the issue by explicitly making sure to set the content-length: https://github.com/phillro/node-elasticsearch-client/blob/master/lib/elasticsearchclient/calls/elasticSearchCall.js#L86 3) How could this be handled in elastic.js?

pulkitsinghal commented 11 years ago

FYI: I was able to ask my team to push configuration changes to the nginx-servers which include support for chunked transfer-encoding ... so I'm no longer running into this problem when using the elasticjs client.

jsilveira commented 10 years ago

¿Shouldn't elastic-node-client add the ''Content-Length' header in the post and put functions to make it compatible with servers that don't support chunking? (like older nginx versions)