-
Notifications
You must be signed in to change notification settings - Fork 666
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
Intermittent RangeError: length > kMaxLength #15
Comments
node version? ssh2 module version? OpenSSH version? |
Also, what kind of key is this? # bits? |
How do I tell you more about the key? |
I'll keep digging, but try the master branch now and set |
I'm sorry, the ssh version I gave above is for my laptop.. here's the output for my server
|
Using the ssh2 version mentioned above, and with
|
I have now checked out the git repository into my node_modules to get the HEAD version as you said, and rerunning the app I get this debug output
|
FWIW I notice you test against OpenSSH 6 .. but the OpenSSH on both my laptop and server are 5.x ... |
Alright, so I've tried everything I can to duplicate this problem on my end (including installing Debian 5) but I cannot get it to break at all. I've even tried bandwidth limiting and latency simulation. Would it be possible for you to hop on IRC sometime to coordinate a way for me to remotely debug? |
I also encountered a Here is the code I was using: var c, ssh2;
ssh2 = require('ssh2');
c = new ssh2();
c.on('connect', function() {
console.log('CONNECTED');
return c.exec('uptime', function(err, stream) {
if (err) {
throw err;
}
return stream.on('data', function(data) {
return console.log(data.toString());
});
});
});
c.on('error', function(err) {
console.log('ERROR', err);
throw err;
return done();
});
c.connect({
host: '192.168.55.101',
port: 22,
username: 'vagrant',
password: 'vagrant',
debug: console.log
}); Here is that code's output with debug set to console.log on connect: vagrant@app:/var/www/martini$ ./node_modules/.bin/coffee test.coffee
CONNECTED
header { greeting: null,
ident_raw: 'SSH-2.0-OpenSSH_6.0p1 Debian-3ubuntu1',
versions: { protocol: '2.0', server: 'OpenSSH_6.0p1' },
comments: 'Debian-3ubuntu1' }
buffer.js:242
this.parent = new SlowBuffer(this.length);
^
RangeError: length > kMaxLength
at new Buffer (buffer.js:242:21)
at Parser.expect (/var/www/martini/node_modules/ssh2/lib/Parser.js:680:25)
at Parser.execute (/var/www/martini/node_modules/ssh2/lib/Parser.js:203:16)
at Socket.Connection.connect._sock.once.err.level (/var/www/martini/node_modules/ssh2/lib/Connection.js:1186:18)
at Socket.EventEmitter.emit (events.js:96:17)
at TCP.onread (net.js:397:14) Here is the modified code with a settimeout that "fixed" the problem for me: var c, ssh2;
ssh2 = require('ssh2');
c = new ssh2();
c.on('connect', function() {
console.log('CONNECTED');
return setTimeout(function() {
return c.exec('uptime', function(err, stream) {
if (err) {
throw err;
}
return stream.on('data', function(data) {
return console.log(data.toString());
});
});
}, 500);
});
c.on('error', function(err) {
console.log('ERROR', err);
throw err;
return done();
});
c.connect({
host: '192.168.55.101',
port: 22,
username: 'vagrant',
password: 'vagrant',
debug: console.log
}); And the modified code's output with debug set to console.log on connect: vagrant@app:/var/www/martini$ ./node_modules/.bin/coffee test.coffee
CONNECTED
header { greeting: null,
ident_raw: 'SSH-2.0-OpenSSH_6.0p1 Debian-3ubuntu1',
versions: { protocol: '2.0', server: 'OpenSSH_6.0p1' },
comments: 'Debian-3ubuntu1' }
packet KEXINIT 20 <Buffer b9 c4 ab 9e 13 fa 73 45 6e eb 51 60 6e 44 ae c2 00 00 00 b7 65 63 64 68 2d 73 68 61 32 2d 6e 69 73 74 70 32 35 36 2c 65 63 64 68 2d 73 68 61 32 2d 6e 69 ...>
packet KEXDH_REPLY 31 <Buffer 00 00 01 17 00 00 00 07 73 73 68 2d 72 73 61 00 00 00 03 01 00 01 00 00 01 01 00 e2 a8 95 ae 26 26 d7 a7 74 63 16 2a ca 8c 6e 8c 4c c1 bf a4 5e 93 86 7e ...>
packet NEWKEYS 21 <Buffer >
packet SERVICE_ACCEPT 6 <Buffer 00 00 00 0c 73 73 68 2d 75 73 65 72 61 75 74 68>
packet USERAUTH_SUCCESS 52 <Buffer >
packet CHANNEL_OPEN_CONFIRMATION 91 <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00>
packet CHANNEL_WINDOW_ADJUST 93 <Buffer 00 00 00 00 00 20 00 00>
packet CHANNEL_SUCCESS 99 <Buffer 00 00 00 00>
packet CHANNEL_DATA 94 <Buffer 00 00 00 00 00 00 00 3e 20 32 30 3a 30 38 3a 35 32 20 75 70 20 31 30 3a 32 36 2c 20 20 30 20 75 73 65 72 73 2c 20 20 6c 6f 61 64 20 61 76 65 72 61 67 65 ...>
20:08:52 up 10:26, 0 users, load average: 0.10, 0.06, 0.06
packet CHANNEL_EOF 96 <Buffer 00 00 00 00>
packet CHANNEL_REQUEST 98 <Buffer 00 00 00 00 00 00 00 0b 65 78 69 74 2d 73 74 61 74 75 73 00 00 00 00 00>
packet CHANNEL_CLOSE 97 <Buffer 00 00 00 00> |
@proksoup you should not use the 'connect' event for issuing commands, it's merely there for if you want to do your own connection timeout algorithm. You need to listen for the 'ready' event instead. |
I noticed you updated the package version in npm, so I updated and reran the script. Now it works fine and even prints out the data from the server. |
Glad to hear it's working for you now! :-) |
I am having this issue as well, I have followed what you said in this thread, and am able to replace it every time. Also seeing duplicate connections generate for some reason when it happens. Where would we be able to chat on irc? |
node -v ssh -v ssh2 - 0.1.11 output happening: buffer.js:242 I am not sure why its doing two connections to each server or why this is happening |
exports.connect = function (hostname, command, onReady) {
conn.connect ({
host: hostname,
port: port,
username: userName,
privateKey: privateKey,
debug: console.log
});
conn.on('connect', function(){
console.log('Connecting to ' + hostname);
});
conn.on('ready', function() {
conn.exec(command, function(err, stream) {
if (err) throw err;
stream.on('data', function(data, extended){
onReady(null, data);
});
stream.on('error', function(err) {
console.log('TCP :: ERROR: ' + err);
});
stream.on('exit', function(code, signal){
if (code != 0) throw new Error('Exit code not 0 from: ' + hostname);
conn.end();
});
});
});
conn.on('error', function(err) {
console.log('Connection :: error :: ' + err);
});
}; |
it simply gets called twice right now, 1 time for each server passing in hostname and command 'uptime' |
D'OH Ive made my corrections, appears to be working now sorry and thanks for the help |
I set up a script using your first example (that runs 'uptime') and configured it for my SSH key to log in to my hosting account on dreamhost. It is intermittently giving an error - and by the way does not print the output from uptime.
Client machine is Mac OS X
Server machine is Dreamhosts version of Debian
The text was updated successfully, but these errors were encountered: