0

I developed an REST API using node.js + express + elastic-search. In that i receive a request and send JSON as response. Everything is working fine.

In a particular situation(say /xxx/yyy/zzz?param1) the response is not sent to the front end. My application simply stays ideal doing nothing. My guess is that for this particular route the JSON response is very bulk i think so.

My code is:

app.get('/xxx/yyy/zzz', function(req, res){
        return Ctr.getMaster(req, res);
    }); 

DAO.prototype.master = function(callback) {
    var query = {
        from: 0,
        size: 1000000,
        index: 'masterdata',
        query:"match_all"
    }
     client.search(query).then(function (resp) {
        var obj = {};
        obj.count = resp.hits.total;
        obj.master = resp.hits.hits;
        callback(null, obj);
     }, function(error){
         console.log(error);
     });
};

How can i sort it out. I want to know whether the JSON is the problem? Or something else?/ How can i crack it. Please share your ideas.

Subburaj
  • 5,114
  • 10
  • 44
  • 87

1 Answers1

0

Press F12 on browser and verify that is request received or not and how much size is there. Moreover, print console log on your backend API for json size.

Take look this one too 8937516

Community
  • 1
  • 1
webpandit
  • 47
  • 4
  • In browser i am receiving 500 Internal Sever Error, so i cant find the size in browser. – Subburaj May 25 '15 at 05:59
  • Then you need to debug your backend API. Using console.log verify query is correct and size of that response JSON. Elastic Search also have configuration of size for response. – webpandit May 25 '15 at 06:11
  • everything is correct the final Json is constructed but the Constructed JSON is not sending back.. – Subburaj May 25 '15 at 06:13
  • Check the response header. Is Content-Type set as application/json?. Irrespective of that I would suggest you to debug the application. You can use eclipse-node-debugger. – years_of_no_light May 25 '15 at 07:04
  • @ Akash Content type is json only.. The same route is working for some parameters.. – Subburaj May 25 '15 at 07:13
  • If you are using body parser then use app.use(bodyParser.json({limit: x})); or to configure at express level app.use(express.json({limit: x})); or in your query size: 1000000 minimize this and you would able to confirm. – webpandit May 25 '15 at 08:46