Home > Enterprise >  Disable ftp connection timeout using ftp npm package in nodejs
Disable ftp connection timeout using ftp npm package in nodejs

Time:04-11

I am using npm ftp and getting the timeout after 10 minutes and i have gone through the ftp package documentation and there is no timeout disable option. If we are going to use basic-ftp npm then there is timeout disable option is there but i haven't found anything in ftp. Yes, there is keepalive params is there in the ftp but i want to keep the connection for always.Is there anything that i am missing while keeping the ftp connection.

` throw er; // Unhandled 'error' event ^

Error: No-transfer-time exceeded. Closing control connection.`

CodePudding user response:

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

Under Methods:

Find connect:

You'd use these within your config object when firing off connect. Just add these additional params in and set the MS for your requirements.

connTimeout - integer - How long (in milliseconds) to wait for the control connection to be established. Default: 10000

pasvTimeout - integer - How long (in milliseconds) to wait for a PASV data connection to be established. Default: 10000

keepalive - integer - How often (in milliseconds) to send a 'dummy' (NOOP) command to keep the connection alive. Default: 10000

Beyond this, the connection could fail so error handle it in that case if you need ftp to reconnect.

CodePudding user response:

try { 
client.connect(credentials); 
console.log("Ftp Server is Connected");
 }
 catch (error) {
 console.log("Error while establish connection with Ftp Server"   error); process.exit(1); 
}

I am trying to handle the error in this way but it is not coming in the catch section

  • Related