mscdex / node-ftp

An FTP client module for node.js
MIT License
1.13k stars 243 forks source link

Getting error of connection unexpectedly closing #157

Closed SteveyPugs closed 8 years ago

SteveyPugs commented 8 years ago
[Error: Timed out while making data connection]
events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: Data connection unexpectedly closed.
    at makeError (\project\node_modules\ftp\lib\connection.js:1067:13)
    at Parser.<anonymous> (\project\node_modules\ftp\lib\connection.js:115:28)
    at emitTwo (events.js:87:13)
    at Parser.emit (events.js:172:7)
    at Parser._write (\project\node_modules\ftp\lib\parser.js:59:10)
    at doWrite (_stream_writable.js:300:12)
    at writeOrBuffer (_stream_writable.js:286:5)
    at Parser.Writable.write (_stream_writable.js:214:11)
    at Socket.ondata (\project\node_modules\ftp\lib\connection.js:273:20)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:153:18)
    at Socket.Readable.push (_stream_readable.js:111:10)
    at TCP.onread (net.js:536:20)

My config is very basic

mt_ftp.connect({
    host: ftp_config.ftphost,
    user: ftp_config.ftpuser,
    password: ftp_config.ftppass
});
SteveyPugs commented 8 years ago

Also, another question is that should I use the error event to handle such things:

https://github.com/mscdex/node-ftp#events

SteveyPugs commented 8 years ago

I am still getting this error except is something more like:

[Error: Unable to make data connection( Error: connect ECONNREFUSED)]

mscdex commented 8 years ago

Yes, add a 'data' event handler for the errors.

As far as the error itself goes, it sounds like something is blocking the data connection. It could be something client side or server side (firewall or otherwise).

SteveyPugs commented 8 years ago

Ok, thanks!

I applied the error event to see what's going on. If I find anything else, I will re-open

woshi82 commented 8 years ago

@SteveyPugs hi,I'am also have this problem. The ftp is not stable,sometimes it connect OK,sometimes broken.

woshi82 commented 8 years ago

@SteveyPugs how did you solved the problem??

SteveyPugs commented 8 years ago

@woshi82 I have really haven't solved this issue. @mscdex it might be due to our FTP login my account out. Is there anything in the code that would allow for reconnection similar to:

https://github.com/realtymaps/promise-ftp#methods

mscdex commented 8 years ago

There is no auto-reconnect at the moment.

woshi82 commented 8 years ago

@SteveyPugs thankyou ,i have solved my problem.i have reduced concurrent in my program,everything goes all right

SteveyPugs commented 8 years ago

BTW best I found to work on a login basis is: https://www.npmjs.com/package/chilkat_node4_win32