mardi 12 juillet 2016

Different response length on public IP than on local

I streaming JSON to browser using x-ray scraper:

app.get('/scrape', function (req, res) {
  // other code
  var stream = x(siteUrl, site.item, site.params)
            .paginate(site.paginate)
            .stream();

  stream.pipe(res);
  // other code
});

And I catch it with ajax onprogress event like below:

$.ajax('/scrape', {
        xhrFields: {
            onprogress: function (e) {
                console.log(e.currentTarget.response.length); // here is problem

                // other code       
            }
        }
    }

And everything here works well on localhost but when I run it through public IP the responses are randomly cut and it looks for example like that (in other words I can't handle response properly because json is cut):

  {
    "title": "Some Title",
    "link": "http://some...

Aucun commentaire:

Enregistrer un commentaire