Code Monkey home page Code Monkey logo

node-scp2's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-scp2's Issues

Basic Typescript Definitions

it might help someone. Here are the definitions I'm using for typescript.

declare module "scp2" {

    interface ScpOptions {
        port?: number;
        host?: string;
        username?: string;
        password?: string;
        paths?: string;
    }

    interface attrs {
        size: number;
        uid: number;
        gid: number;
        mode: number | string;
        atime: number;
        mtime: number;
    }

    interface writeOptions {
        destination: string;
        content: string;
        attrs: attrs;
        source: string;
    }

    export class Client {
        constructor(options: ScpOptions);
        sftp(callback: (err: string, sftp: Client) => void);
        close(): void;
        mkdir(dir: string, attrs: attrs, callback: (err: string) => void);
        write(options: writeOptions, callback: (err: string) => void);
        upload(src: string, destination: string, callback: (err: string) => void);
        download(src: string, destination: string, callback: (err: string) => void);
        on(eventName: string, callback: () => void);
    }

    export interface client {
        defaults(options: ScpOptions);
        scp(fileName: string, options: ScpOptions | string, errCallback?: (err: string) => void);
        scp(fileName: string, options: ScpOptions | string, glob: string, errCallback?: (err: string) => void);
    }
}

And now you can use it as

import { Client } from 'scp2';

let client = new Client({
    port: 22
});

Infinite recursion on sftp upward traversal; causes call stack overflow

Hey @lepture,

Thanks for this package! I really like what you've done with scp2. It has been working very well for my uses except for the one bug I keep seeing repeatedly.

The Issue

Some of my SCP operations copy entire directories via SCP. During a fraction of these operations, I see the following error thrown:

/Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:873
    err = new Error('Underlying stream not writable');
          ^
RangeError: Maximum call stack size exceeded
    at new Error (native)
    at SFTP._send (/Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:873:11)
    at SFTP.stat (/Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:627:15)
    at /Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/lib/client.js:130:12
    at Object.async.until (/Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/node_modules/async/lib/async.js:647:13)
    at /Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/node_modules/async/lib/async.js:651:23
    at /Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/lib/client.js:137:9
    at SFTP._send (/Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:875:7)
    at SFTP.stat (/Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:627:15)
    at /Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/lib/client.js:130:12

I've narrowed it down to scp2/lib/client.js as follows.

Debugging the Error

Below is a visual representation of the stack overflow taken from node-debug:

screen_shot_2014-05-12_at_8_09_40_am

I inserted some debug lines into the subroutine inside Client.prototype.mkdir as shown:

/* Line */
/* 130 */   sftp.stat(dir, function(err, attr) {
/* 131 */     console.log('ERR:  ', err);
/* 132 */     console.log('DIR:  ', dir);
/* 133 */     console.log('DIRS: ', dirs);
/* 134 */     if (err) {
/* 135 */       dirs.push(dir);

These debug lines produced the following output during program runtime:

ERR:   [Error: Underlying stream not writable]
DIR:   /home/public/ieee-checkin
DIRS:  []
ERR:   [Error: Underlying stream not writable]
DIR:   /home/public
DIRS:  [ '/home/public/ieee-checkin' ]
ERR:   [Error: Underlying stream not writable]
DIR:   /home
DIRS:  [ '/home/public/ieee-checkin', '/home/public' ]
ERR:   [Error: Underlying stream not writable]
DIR:   /
DIRS:  [ '/home/public/ieee-checkin', '/home/public', '/home' ]
ERR:   [Error: Underlying stream not writable]
DIR:   /
DIRS:  [ '/home/public/ieee-checkin', '/home/public', '/home', '/' ]
ERR:   [Error: Underlying stream not writable]
DIR:   /
DIRS:  [ '/home/public/ieee-checkin', '/home/public', '/home', '/', '/' ]
ERR:   [Error: Underlying stream not writable]
DIR:   /
DIRS:  [ '/home/public/ieee-checkin', '/home/public', '/home', '/', '/', '/' ]
ERR:   [Error: Underlying stream not writable]
DIR:   /
DIRS:  [ '/home/public/ieee-checkin', '/home/public', '/home', '/', '/', '/', '/' ]
...continues...

Once the program hit the call stack limit, it crashed.

Diagnosis

It looks like the program is attempting to create a directory, but failing due to the Underlying stream not writable error.

I believe you're trying to handle this error:

ERR:   { [Error: No such file] type: 'NO_SUCH_FILE', lang: '' }

I think your code is seeing the Underlying stream not writable error, catching it as if it were a NO_SUCH_FILE error, and proceeds to assume the directory in which it's trying to mkdir doesn't exist. Because of this, the function continues to iterate up the directory tree and continues to get that error and attempt recursion until the call stack overflows.

Suggestions

  • Only catch the NO_SUCH_FILE error. Let all other errors throw. I'm working on a patch for that for my code.
  • Alternately, figure out why the Underlying stream not writable error appears. It stems from line 892 in SFTPv3.js in the ssh2 library.

Edit: New discovery!

Possible root cause

Underlying stream not writable appears if I call the same hook twice in a row, connecting to the same server and uploading the same files using the same password/key.

This leads me to believe that Client.prototype.close is not being called properly and possibly that I am reusing the sftp object in an improper way. Does any of this sound right?

Fix based on possible root cause

I've implemented changes to scp.js that mitigate this problem.

The changes involve making the client object in scp.js no longer a singleton pointing to a once-instantiated new Client().

Instead, Client is imported as follows:

var Client = require('./client').Client;

and client is set to an instance of Client:

var client = new Client();

Then, each time scp is called, client is reinstantiated:

exports.scp = function(src, dest, callback) {
  client = new Client();
  /* ... other code ... */
};

This may be wasteful and it may trigger garbage collection more often, but it is a functional workaround that I will use for the time being.

tl;dr: using a new Client for each scp(...) solves this problem on my machine

Other Info

My system versions are as follows:

Node 0.11.9
scp2 0.1.4
OS X 10.9.3

I'm not sure if there's any way for you to reproduce this on your machine or if you've seen this before. I'm happy to help out.

I'm connecting via SCP with password to a NearlyFreeSpeech server. I think this issue may be server-system-specific or server-SCP-version-specific. I don't think that any more—see suggestion #2.

Let me know what you think. Thanks for taking a look!

Matt

Error: Underlying stream not writable when trying to download file from remote server to node server

Hi,

I am trying to download a file from a remote linux server (from directory /home/dataFiles/test.txt) into node server (to directory H:/dataDirOnNodeServer). In order to do so I run the following:

client.scp('linuxUsername:linuxPassword@linuxserverName:/home/dataFiles/test.txt', 'H:/dataDirOnNodeServer', function(err) {
console.log(err);
})

I get an error: Error: Underlying stream not writable

I would really appreciate it if you can help me with this.

Many Thanks.

Ana

copying big file fails

I'm downloading a 25mb zip file from sftp. Zip has one csv file in UTF.

scp2 downloads 25.8 MB (27,103,241 bytes) instead of 25.8 MB (27,103,654 bytes).

tried couple of times locally and remote. Any suggestions why this is happen?

connection seems to stay open when copying from server to client

Using this form:

client.scp({
    host: 'example.com',
    username: 'admin',
    password: 'password',
    path: '/home/admin/file.txt'
}, './', function(err) {})

It seems that the ssh connection is staying open. No problem when copying from the client to the server though, but I see they take two different code paths.

Bytes transfered event in download method

Not sure if there is anyway to do this currently and if so let me know.
I am looking for a way to setup a listener on the client to capture, on an interval, the progress of the file being downloaded.

Example:

client = new Scp2.Client config
    client.on 'transfer', (bytes) ->
      Logger.verbose "Bytes transfered (#{localFile}): #{bytes}"
    client.download remoteFile, localFile, (error) ->
      callback error, localFile

The only place that the 'transfer' event is currently emitted is in the Client.write method.

I made a Gist with some minor updates to Client.prototype.download to emit this.
Any comments/thoughts?
https://gist.github.com/charlietilt/8d6c64b50ebf688b47e1

Exception while instantiating scp

am using scp2 for file transfer in my Node.js program. As per the instruction on npmjs.com, I tried to do following:

var Client = require('scp2').Client;

var client = new Client({
port: 22
});

But in the above code, the program fails to instantiate Client and it complains that Client is undefined. Am I missing somthing in the document? Can you please help?

Deprecation warnings on Node 6

Using scp2 under Node 6 throws deprecation warnings for graceful-fs (used by glob 4.x).

fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.

npm outdated returns the following

Package     Current  Wanted      Latest  Location
async         0.9.2   0.9.2  2.0.0-rc.3  scp2
glob          4.0.6   4.0.6       7.0.3  scp2
jscoverage    0.5.9   0.5.9       0.6.0  scp2
lodash        2.4.2   2.4.2      4.11.1  scp2
ssh2         0.4.15  0.4.15       0.5.0  scp2

The latest version of glob (7.0.3 as of today) does not directly use graceful-fs anymore (although it is pulled in later down the line by a dev dependency, but as [email protected]).

The best thing to do would be to update all of the dependencies. Thoughts?

upload is fake

hello, I am using scp2.client to using sftp to upload the files, it uses upload function and showing correct path and its showing file uploaded successfully but when I see in ftp server the file does not uploaded.. can you please help..

Empty file created on NO_SUCH_FILE error

Using the following type of call:

client.scp({
    host: 'example.com',
    username: 'admin',
    password: 'password',
    path: '/home/admin/file.txt'
}, './', function(err) {})

When an attempt to copy a file that doesn't exist occurs, the err object in the callback function has a type property of NO_SUCH_FILE. This is great. However an empty file is still created at the target location. How do I stop this from happening?

Process hangs on overwriting file

I am uploading a pdf file to an sftp server using your module, but the process is hanging if the file already exists.

Local file is chmod to 777.

var Service,
    client = require('scp2'),
    Q = require('q'),
    fs = require('fs');

Service = function () {};

Service.prototype.uploadFile = function (conn, settings, path) {
    var deferred,
        filename = path.substring(path.lastIndexOf('/') + 1);

    deferred = Q.defer();

    client.scp(path, {
        host: settings.host,
        username: settings.user,
        password: settings.password,
        path: settings.path
    }, function (error) {
        if (error) {
            console.log('Error');

            deferred.reject(error);
        }

        client.close();
        console.log('Callback called.');
        deferred.resolve(path);
    });

    return deferred.promise;
};

module.exports = Service;

Is this a known issue? I'm fairly certain i'm using the module as intended.

using scp2 in node-webkit

Hello:
node-scp2 is a good tool to upload or download file from remote. When I use client.scp method in node-webkit, I meet a problem: first time the code run perfectly, but when I click the upload button to run this code again, it throw an exception. It refuse me. After I look over the scp2 source code, I found this in scp.jsfile:

async.eachSeries(files, function(fpath, done) {
  fs.stat(fpath, function(err, stats) {
    if (err) {
      done(err);
      return;
    }
    if (stats.isFile()) {
      var fname = path.relative(rootdir, fpath);
      client.upload(
        fpath, path.join(client.remote.path, fname), done
      );
    } else {
      done();
    }
  });
}, function(err) {
  // never forget to close the session close by myself
  client.on('close', function() {
    callback(err);
  });
  client.close();
});

This problem is because that after client.scp method, it close the connection automatically, so next time when I run this method, the code throw an error!

I suggest that whether client.scp method can add a parameter like autoclose: false?? so user can choose whether the connection should be closed or not.

Thanks!!

client.write - Content should be buffer or file descriptor

When I try to write a file with contents as given in example, it comes back with error:

C:\  .... node_modules\scp2\lib\client.js:228
        throw new Error('Content should be buffer or file descriptor');

My code

createFileOnScriptEnginer = function(contents,destinationPath){
  var Client = require('scp2').Client;
  var cl = new Client({
    port: 22,
    host: "10.xxx.xxx.131",
    username: "root",
    privateKey: require('fs').readFileSync("server/components/ssh/ssh_key"),
  });
  cl.write({
    destination: destinationPath,
    content: contents
  }, function(err){

  })
};

createFileOnScriptEnginer('sdfdddddddddsfd','/tmp/testfile.txt');

And the I tried to create Buffer like below. And this time it creates the file but program hangs.

exports.createFileOnScriptEnginer = function(contents,destinationPath){
  var Client = require('scp2').Client;
  var buffer = new Buffer(contents, "utf-8")
  var cl = new Client({
    port: 22,
    host: "10.xxx.xxx.131",
    username: "root",
    privateKey: require('fs').readFileSync("server/components/ssh/ssh_key"),
  });
  cl.write({
    destination: destinationPath,
    content: buffer
  }, function(err){

  })
};

Files over 65536 bytes get corrupted on download

Downloading any type of files works great, unless their size is over 65536 bytes.

For files over 65k, it looks like the download went well (no err in the callback) but they get corrupted after the first 65536 bytes. I can attach an example of a file before and after if needed.

I also tried over an external network, as well as a local network (guest + vm) but the issue remains.

I may be missing some special configuration for larger files?

Here is the testing code I'm using:

var client = require('scp2');
  client.scp({
    host: 'the-remote-host',
    username: 'the-remote-username',
    password: 'the-remote-password',
    path: path.join('/tmp', 'file.tar')
  }, path.join(process.cwd(), 'file.tar'), function (err) {
    if (err) {
      console.log('Unable to get the file back! ');
      client.close();
    } else {
      console.log('File downloaded successfully');
      client.close();
    }
  });

Let me know if I can do anything else to help...
Thanks!

Update version for ssh2

I am running into an issue that has already been resolved in ssh2: mscdex/ssh2#263

However, since scp2 package.json uses an old version of ssh2, this issue is not yet fixed. I can work around this by manully updating the ssh2 version used by scp2, but it would be nice to be able to npm install and have it work out of the box.

Current version of ssh2 at the time of this writing is 0.4.10.

Thanks!

Module crash application - Error: Unable to start subsystem: sftp

The module crash the application when copying file to a machine without sftp, even when called with yield inside try-catch statement or with listening to scp.on('error', cb):

Error: Unable to start subsystem: sftp
    at /.../node_modules/scp2/node_modules/ssh2/lib/client.js:1283:19
    at SSH2Stream.<anonymous> (/.../node_modules/scp2/node_modules/ssh2/lib/Channel.js:185:24)
    at emitNone (events.js:86:13)
    at SSH2Stream.emit (events.js:185:7)
    at parsePacket (/.../node_modules/scp2/node_modules/ssh2-streams/lib/ssh.js:3225:10)
    at SSH2Stream._transform (/.../node_modules/scp2/node_modules/ssh2-streams/lib/ssh.js:551:13)
    at SSH2Stream.Transform._read (_stream_transform.js:167:10)
    at SSH2Stream._read (/.../node_modules/scp2/node_modules/ssh2-streams/lib/ssh.js:212:15)
    at SSH2Stream.Transform._write (_stream_transform.js:155:12)
    at doWrite (_stream_writable.js:307:12)
    at writeOrBuffer (_stream_writable.js:293:5)
    at SSH2Stream.Writable.write (_stream_writable.js:220:11)
    at Socket.ondata (_stream_readable.js:555:20)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:172:18)

bumping min version when change public api

noticed that the public api has been changed from 0.2.0 to 0.2.1, this is terrible while lots of people may install this module and use '~' to indicate the version, it's better to change to min version if any public api was changed

"Write after End" when scping a directory

I am attempting to copy a directory remotely using SSH and public-key method. It will work once, and then I get this on the next attempt to upload.

Error: write after end
    at writeAfterEnd (_stream_writable.js:132:12)
    at ChannelStream.Writable.write (_stream_writable.js:180:5)
    at SFTP._send (/usr/local/app/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:1017:23)
    at SFTP.stat (/usr/local/app/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:750:15)
    at /usr/local/app/node_modules/scp2/lib/client.js:134:12
    at Object.async.until (/usr/local/app/node_modules/async/lib/async.js:707:13)
    at /usr/local/app/node_modules/scp2/lib/client.js:130:11
    at Client.sftp (/usr/local/app/node_modules/scp2/lib/client.js:50:5)
    at Client.mkdir (/usr/local/app/node_modules/scp2/lib/client.js:119:8)
    at /usr/local/app/node_modules/scp2/lib/client.js:257:14

The app then restarts and I'm able to make the request once again. It seems like one of the streams being used isn't being closed correctly or isn't be recreated when the scp call is made again?

Bad destination of .scp throws error "handle is not a Buffer"

If the second parameter of .scp, the destination, is invalid it throws an undescriptive (IMHO) error message "handle is not a Buffer".

Example:

client.scp('file.txt', 'admin:[email protected]:/home/blah/', function(err) {...}) 

...where "/home/blah" doesn't exist.

In client.js at the end of Client.prototype.write() is:

sftp.open(destination, 'w', attrs, function(err, handle) {
  _write(handle);
});

I'm interpreting that the code at this point has already decided that the destination isn't absolute so it assumes that its relative, prepends a path, but after calling sftp.open() again it doesn't check the return value of err before calling _write().

The solution could be to check the value of err and act accordingly:

sftp.open(destination, 'w', attrs, function(err, handle) {
  if (err)
    throw new Error('Destination is invalid');
  _write(handle);
});

--port/-p option not working on command line

running the command scp2 -p 1234 localfile server throws:

{ [Error: connect ECONNREFUSED SERVER-IP]
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: 'SERVER-IP',
  port: 22,
  level: 'client-socket' }

notice that the port on the error is still 22 and not 1234 as specified

ERROR: Argument must be a string

Unable to get a copy from client to server working. Getting:

Message:
    Argument must be a string
Details:
    domain: [object Object]
    domainThrown: true
Stack:
TypeError: Argument must be a string
    at Connection._authNone (/home/brendanjerwin/projects/asset-server/services/asset-server/node_modules/scp2/node_modules/ssh2/lib/Connection.js:1336:24)
    at onSERVICE_ACCEPT (/home/brendanjerwin/projects/asset-server/services/asset-server/node_modules/scp2/node_modules/ssh2/lib/Connection.js:2412:12)
    at Parser.<anonymous> (/home/brendanjerwin/projects/asset-server/services/asset-server/node_modules/scp2/node_modules/ssh2/lib/Connection.js:133:5)
    at Parser.emit (events.js:95:17)
    at Parser.parsePacket (/home/brendanjerwin/projects/asset-server/services/asset-server/node_modules/scp2/node_modules/ssh2/lib/Parser.js:474:12)
    at Parser.execute (/home/brendanjerwin/projects/asset-server/services/asset-server/node_modules/scp2/node_modules/ssh2/lib/Parser.js:249:14)
    at Socket.<anonymous> (/home/brendanjerwin/projects/asset-server/services/asset-server/node_modules/scp2/node_modules/ssh2/lib/Connection.js:536:18)
    at Socket.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:765:14)
    at Socket.emit (events.js:92:17)

Calling it like this:

scpClient.scp(assetSourcePath, sshOptions, function (err) {
                if (err) {
                    trace('Error while scp: %s', err);
                } else {
                    trace('Copy completed.');
                }
           });

Where sshOptions looks something like this:

{ host: 'localhost', path: '/tmp/asset_build.QCvR' }

Can't download large files

Tried downloading a 30,000 row csv file and it only gave me the first 423 rows.
I like the way it's supposed to function, but it's obviously not useful if it's returning partial files. Not seeing any errors even.

17 Oct 17:43:43 - connected
17 Oct 17:43:43 - ready
17 Oct 17:43:44 - read /tmp/xxxxxx.csv
17 Oct 17:43:44 - scp success

Hope you get it fixed, i'd love to use this module.

"glob *" writes to wrong destination folder

Source
OS: Windows 7
Pattern: C:\Users\aaa\bbb\ccc*

Destination
OS: Linux
Folder: /home/target/out/

Expected Result
Everything in source folder C:\Users\aaa\bbb\ccc should be copied into destination directory /home/target/out/ (which already exists when scp is called)

Actual Result
Only the first file from the source folder is copied to the correct destination folder. All other files are copied to the PARENT folder of the destination folder instead, i.e. to /home/target/ instead of /home/target/out/

Sample Code

function run(srcFolder, dstConfig, cb) {

    var src = path.join(srcFolder, "*");

    // the following shows C:\Users\aaa\bbb\ccc\*
    console.log("source pattern: " + src);

    // the following shows /home/target/out/
    console.log("destination folder: " + dstConfig.path);

    scp(src, dstConfig, function(err) {
        cb(err);
    });
}

privateKey Documentation

After some trials of not getting the privateKey to work, we finally found that we need to initialize this library using:

var scp =  require('scp2');

var client = new scp.Client({
    host : config.sshHost
    port  : config.sshPort,
    username  : config.sshUser,
    privateKey : config.sshPrivatekey
});

This was rather unclear in the documentation and is recommended to be updated.

Unable to close connection

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()
  }
})

set max connection?

(node) warning: possible EventEmitter memory leak detected. 11 close listeners added. Use emitter.setMaxListeners() to increase limit.

please help me

Error: Offset is out of bounds

看了一下服务器,文件是可以正常上传的,但出现一个没有catch的error如下:

fs.js:457
  binding.read(fd, buffer, offset, length, position, wrapper);
          ^
Error: Offset is out of bounds
    at Object.fs.read (fs.js:457:11)
    at /Library/WebServer/Documents/coder/node_modules/scp2/lib/client.js:192:14
    at iterate (/Library/WebServer/Documents/coder/node_modules/scp2/node_modules/async/lib/async.js:131:13)
    at Object.async.eachSeries (/Library/WebServer/Documents/coder/node_modules/scp2/node_modules/async/lib/async.js:147:9)
    at _write (/Library/WebServer/Documents/coder/node_modules/scp2/lib/client.js:189:15)
    at /Library/WebServer/Documents/coder/node_modules/scp2/lib/client.js:221:11
    at SFTP._parse (/Library/WebServer/Documents/coder/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:978:11)
    at ChannelStream.<anonymous> (/Library/WebServer/Documents/coder/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:49:12)
    at ChannelStream.EventEmitter.emit [as _emit] (events.js:95:17)
    at ChannelStream.emit (/Library/WebServer/Documents/coder/node_modules/scp2/node_modules/ssh2/lib/Channel.js:547:12)

node version: v0.10.12
npm version: 1.2.32
scp2: lastest

Menu 样式问题

  1. MenuItem 中有 a 时,disabled 属性不生效。
  2. dark 主题的样式有问题。

Maintainer Wanted

This repo is not maintained well. I have too many organizations and too many projects, I can't spare much time in this project any more.

Anyone (one or more) wants to maintain this repo?

How to alter timeout?

[14:41:42] 'js:upload' errored after 10 s
[14:41:42] Error: Timed out while waiting for handshake
  at [object Object]._onTimeout (/home/adones/Projects/chaipcr/node_modules/scp2/node_modules/ssh2/lib/Connection.js:232:17)
  at Timer.listOnTimeout (timers.js:119:15)

Exports client

In the commit on January 31, added export customer d069d91, but after this version has not changed. Accordingly, here is a code causes an error:

var Client = require('scp2').Client;
var client = new Client({
port: 22
});

Thrown error when destination folder incorrect or wrong permissions

Hi!
I'm currently having a bit of trouble concerning my upload function :

    client.on('error', function(err) {
        return res.status(500).json({
            message: 'Error when sending image to media server',
            error: err
        });
    });

    client.upload(req.file.path, '/home2/myhome/'+image.storedName, function (err) {
        if (err) {
            return res.status(500).json({
                message: 'Error when sending image to media server',
                error: err
            });
        }

        image.fullUrl = config.mediaURL + image.storedName;
        image.save(function (err, image) {
            if (err) {
                return res.status(500).json({
                    message: 'Error when saving image',
                    error: err
                });
            }
            return res.status(201).send();
        });
    });

If the destination file is incorrect or my permissions are wrong I get this error :
/Users/Nicolas/Documents/Davidson/Adeo/Mobility/feedback-product/node_modules/ssh2-streams/lib/sftp.js:878 throw new Error('handle is not a Buffer');

Am I missing something, or is ssh2-streams not managing the error correctly ? (As far as I know you're not supposed to throw errors in async functions in NodeJs, only return them)

Listening to 'error' event is required when having bad ssh authentication credentials.

If client is not listening to the error event when authenticating with bad credentials an uncaughtException will be thrown which is hard to try/catch and will crash your app instead of giving the error in the callback.

var scp = require('scp2');
var client = new scp.Client({
    port: 22,
    host: 'localhost',
    username: 'test',
    password: 'pass'
});

//client.on('error', function(err) {
//  console.log('got event error', err)
//})

client.upload('/tmp/wat.tmp', '/srv/www/wat.tmp', function(err) {
    console.log('got err', err)
});

Uncommenting the listener in the code above will cause the callback to pass the err however this should be fixed or better documented in the README.

I handle my err logic in the callback so the fix for me is to add a client.on('error', function(){}) somewhere

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.