spmjs / node-scp2

[MAINTAINER WANTED] A pure javascript scp program based on ssh2.
384 stars 96 forks source link

Unable to close connection #53

Open reggi opened 8 years ago

reggi commented 8 years ago

Hey @spmjs thanks for the awesome libray!

I'm unable to close the connection. I have a really simple example like this. No errors occur and the process never exists. Any help would be amazing.

import scpClient from 'scp2'
scpClient.scp(source, dest, function(err) {
  if (err) {
    scpClient.close()
    return reject(err)
  } else {
    scpClient.close()
    return resolve()
  }
})
reggi commented 8 years ago

Hey @lepture is there any way to close a connection? My process doesn't end with .close()?

My code is very simple and still wont close :(

import scpClient from 'scp2'

const SSH_HOST = process.env.SSH_HOST
const SSH_USER = process.env.SSH_USER
const SSH_PASS = process.env.SSH_PASS

let buildSCPFile = (file) => `${SSH_USER}:${SSH_PASS}@${SSH_HOST}:/home/user/temp/${file}`

scpClient.scp(buildSCPFile('file.sql'), './temp/file.sql', function(err) {
  console.log('done')
  scpClient.close()
})
rw355 commented 7 years ago

I think scpClient.close() closes the ssh session. To close your process, you can do:

process.exit();