Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: ECONNRESET #103

Closed
lklepner opened this issue Sep 26, 2014 · 8 comments
Closed

Error: ECONNRESET #103

lklepner opened this issue Sep 26, 2014 · 8 comments

Comments

@lklepner
Copy link

Hi,

I'm having trouble determining the proper way to handle ECONNRESET errors which are currently causing my app to quit with the following error --

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: read ECONNRESET
    at errnoException (net.js:904:11)
    at TCP.onread (net.js:558:19)

Here is my code --

var ftp = new JSFtp({
  host: IP,
  port: 21,
  user: user,
  pass: pass,
  debugMode: false
})


ftp.on('error', function(err){
     console.log('onFTPError: ' + err)
})

ftp.put(localPath, destinationPath, function(hadErr) {
     if (hadErr) console.log('putFile error: ' + hadErr)
     if (!hadErr) {
    console.log("File transferred successfully, next quit")
    ftp.raw.quit(function(err, data) {
        if (err){
                console.error('ftp quit error: ' + err);
            } else {
            console.log('server closed')
            }
    })
    }
})

Thanks,
Lou

@lklepner lklepner changed the title ECONNRESET error error ECONNRESET Sep 26, 2014
@lklepner lklepner changed the title error ECONNRESET Error: ECONNRESET Sep 26, 2014
@vietkute02
Copy link

Hi,
I've similar error , when i run ftp.put

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: connect ETIMEDOUT
    at errnoException (net.js:904:11)
    at Object.afterConnect [as oncomplete] (net.js:895:19)

@dypsilon
Copy link

Hi,

I have simillar problem. I'm uploading a list files to the remote ftp host and getting random ECONNRESET errors on file upload. It's always some other file.

The problem appears only with debug = off. A working workaround for me is to put a timeout of 200ms between file uploads.

@Farmy
Copy link

Farmy commented Feb 2, 2015

Without having any idea of how the ftp protocol works and being a javascript/node.js - noob I think the problem is that jsftp registeres to the 'error'-Event of the pasv socket used to PUT files only in the callback of the self.execute. This creates a time span where the socket is created but without error handler. If it gets closed before jsftp issued the STOR command (or if it is closed as reaction to the STOR command...) the ECONNRESET event is without handler.

I (apparently) fixed this problem by moving the socket event listener registration out of the inner callback function into the outer "getPasvSocket"

  this.getPasvSocket(function(err, socket) {
    if (err) return _callback(err);
    socket.on('close', doneCallback);
    socket.on('error', doneCallback);    

    var putCallback = once(function putCallback(err, res) {
      if (err) return _callback(err);

      // Mark 150 indicates that the 'STOR' socket is ready to receive data.
      // Anything else is not relevant.
      if (res.code === 125 || res.code === 150) {
        self.pasvTimeout.call(self, socket, doneCallback);
        _callback(null, socket);
      } else {
        return _callback(new Error('Unexpected command ' + res.text));
      }
    });

@samkohli
Copy link

samkohli commented Apr 9, 2015

I am still having this error when I run:
var connectionProperties = {
host: "",
port: 21, // defaults to 21
user: "anonymous", // defaults to "anonymous"
pass: "anonymous", // defaults to "@anonymous"
debugMode: true
};

    var c = new JSFtp(connectionProperties);
    c.get(fullreadpath, fullwritepath + "/" + file, function(hadErr) 

events.js:72
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at errnoException (net.js:904:11)
at TCP.onread (net.js:558:19)

@ddliu
Copy link

ddliu commented Apr 10, 2015

Same issue here when trying to put files in parallel , creating new JSFtp instance for each file works.

See #66

@ka-sh
Copy link

ka-sh commented Jan 4, 2016

I think this issue is related to node it self nodejs/node#3595

@vladimirkrasulya-planorama

Hello guys , it happen because FTP server drop connection , so you need to handle this error in the same way you handle other network errors, don't forget to set .on('error') on JSFTP instance - since it's EventEmiter.

@sergi sergi closed this as completed Oct 31, 2016
@christiaanwesterbeek
Copy link

Same problem now in 2017. The solution provided by @dypsilon in 2014 still works today. Normally I would just through in a smiley or hooray icon at the comment that helped. But due to the large time span between a helpful solution and now, a comment like this seemed appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants