Friday, 7 April 2017

nodejs request can't download a zip file memory Leak error

Trying to download and do things with a public zip file. My problem is within the download.

Searched on StackOverflow and github repositories with no direct answer, cant figure it out what i'm doing wrong with this simples request

If you access with browser it's working.

request('http://www1.caixa.gov.br/loterias/_arquivos/loterias/D_lotfac.zip') .pipe(fs.createWriteStream(´./arquivos/resultado_${moment().format("YYYYMMDD")}.zip´)) .on('close', function () { console.log('Terminou carga'); });

(node:7548) Warning: Possible EventEmitter memory leak detected. 11 pipe listeners added. Use emitter.setMaxListeners() to increase limit stream.js:74 throw er; // Unhandled stream error in pipe. ^ Error: Exceeded maxRedirects.

So i did this

require('events').EventEmitter.defaultMaxListeners = Infinity;

And found

Error: Exceeded maxRedirects. Probably stuck in a redirect loop http://www1.caixa.gov.br/loterias/_arquivos/loterias/D_lotfac.zip

Is the website preventing me from downloading ir somehow? Is it possible to download this?



via RafaelCarmo

No comments:

Post a Comment