node-ftp icon indicating copy to clipboard operation
node-ftp copied to clipboard

Callback sometimes not called with get

Open cfurst opened this issue 11 years ago • 6 comments

For some reason either the callback function is not called when get is executed or the console write stream is lost. This is when you connect to a server and then call .get wthin an anonymous function context :

var client = new FtpClient(); client.on('ready', function() { client.list('.', function(err, files) { for (var i = 0; i<files.length; i++) { (function(k) { client.get(files[k].name, function(err, stream) { console.log("k is" + k); //doesn't appear is this getting called?? }) //end get })(i) //end anon func } //end for }) // end list }) //end on ready client.connect(params);

Now I admit I'm a bit of a noob however any suggestion on what's going on would be most helpful.

Thanks, Carl

cfurst avatar Apr 25 '14 15:04 cfurst

I've also noticed that the streams are lost, callbacks are called two three times with connections lost. All in all not a very reliable client IMO. If I try and download a directory with 50 files..less than half make it to local disk. Have you experienced this?

cfurst avatar Apr 29 '14 15:04 cfurst

I'm in the same boat.

I list the files in a dir and then in a loop attempt to read them and the callback method for get does not get called with stream.

Any ideas?

jsatk avatar Mar 28 '16 19:03 jsatk

same behaviour that @jsatk , list the files and do get on each file one by one but it stops ramdomly

any ideas ?

sdnetwork avatar Oct 13 '16 20:10 sdnetwork

@sdnetwork @jsatk @cfurst Any luck getting this library to work work reliably? I'm having major intermittent issues with it just stopping and hanging doing simple things like looping through getting and putting a lot of files. Have you tried adding the following debug option to see if it gives clues? I'm having this problem due to the FTP server sending a "451-Error during read from data connection: Resource temporarily unavailable" error. This library just seems to completely hang forever if this happens.

debug: console.log

dustinbolton avatar Mar 25 '17 05:03 dustinbolton

I've abandoned it. We went with a different non-ftp solution.

Iphonicized and mobilized.

On Mar 25, 2017, at 1:42 AM, Dustin Bolton <[email protected]mailto:[email protected]> wrote:

@sdnetworkhttps://github.com/sdnetwork @jsatkhttps://github.com/jsatk @cfursthttps://github.com/cfurst Any luck getting this library to work work reliably? I'm having major intermittent issues. Have you tried adding the following debug option to see if it gives clues? I'm having this problem due to the FTP server sending a "451-Error during read from data connection: Resource temporarily unavailable" error. This library just seems to completely hang forever if this happens.

debug: console.log

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/mscdex/node-ftp/issues/85#issuecomment-289190800, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHEFcBrmbimrvW3hCTuI3OdBveSYIM5fks5rpKjpgaJpZM4B1jkt.


[http://corpweb.mlb.com/MLB_COM_Disclaimed1.png]http://atmlb.com/2eBNAik

cfurst avatar Mar 25 '17 06:03 cfurst

Here's a sanitized version of what worked for us @sdnetwork @dustinbolton @cfurst !

import path from 'path'
import Promise from 'bluebird'

const client = Promise.promisifyAll(new Client())

client.onAsync('ready')
  .then(() => client.listAsync(readDir)
    .map(fileInfo => client.getAsync(path.join(readDir, fileInfo.name))
    .then(stream => doStuffWithStream(stream, path.join(readDir, fileInfo.name))),
      {concurrency: options.concurrency}));

jsatk avatar Mar 29 '17 05:03 jsatk