{"action":"closed","issue":{"url":"https://api.github.com/repos/mscdex/ssh2/issues/181","labels_url":"https://api.github.com/repos/mscdex/ssh2/issues/181/labels{/name}","comments_url":"https://api.github.com/repos/mscdex/ssh2/issues/181/comments","events_url":"https://api.github.com/repos/mscdex/ssh2/issues/181/events","html_url":"https://github.com/mscdex/ssh2/issues/181","id":46017168,"number":181,"title":"Connection hopping not disconnecting","user":{"login":"jacinto123","id":1666324,"avatar_url":"https://avatars.githubusercontent.com/u/1666324?v=3","gravatar_id":"","url":"https://api.github.com/users/jacinto123","html_url":"https://github.com/jacinto123","followers_url":"https://api.github.com/users/jacinto123/followers","following_url":"https://api.github.com/users/jacinto123/following{/other_user}","gists_url":"https://api.github.com/users/jacinto123/gists{/gist_id}","starred_url":"https://api.github.com/users/jacinto123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacinto123/subscriptions","organizations_url":"https://api.github.com/users/jacinto123/orgs","repos_url":"https://api.github.com/users/jacinto123/repos","events_url":"https://api.github.com/users/jacinto123/events{/privacy}","received_events_url":"https://api.github.com/users/jacinto123/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-10-16T18:09:06Z","updated_at":"2015-04-05T15:20:54Z","closed_at":"2015-04-05T15:20:54Z","body":"I am using the basic example from the readme and when completed it disconnects but if I change the operation to cd in a directory and the pull from github it does not disconnect. Thoughts?\r\n\r\nHere is the tail end of the debug log:\r\n\r\nAlready up-to-date.\r\n\r\n```\r\nDEBUG: Parser: STATE_PACKETBEFORE (expecting 16)\r\nDEBUG: Parser: STATE_PACKETBEFORE (expecting 16)\r\nDEBUG: Parser: STATE_PACKET\r\nDEBUG: Parser: Decrypting\r\nDEBUG: Parser: pktLen:156,padLen:18,remainLen:144\r\nDEBUG: Parser: STATE_PACKETDATA\r\nDEBUG: Parser: Decrypting\r\nDEBUG: Parser: hmacSize:16\r\nDEBUG: Parser: STATE_PACKETDATAVERIFY\r\nDEBUG: Parser: Verifying MAC\r\nDEBUG: Parser: STATE_PACKETDATAAFTER, packet: CHANNEL_DATA\r\nDEBUG: Parser: STATE_PACKET\r\nDEBUG: Parser: Decrypting\r\nDEBUG: Parser: pktLen:44,padLen:18,remainLen:32\r\nDEBUG: Parser: STATE_PACKETDATA\r\nDEBUG: Parser: Decrypting\r\nDEBUG: Parser: hmacSize:16\r\nDEBUG: Parser: STATE_PACKETDATAVERIFY\r\nDEBUG: Parser: Verifying MAC\r\nDEBUG: Parser: STATE_PACKETDATAAFTER, packet: CHANNEL_REQUEST\r\nDEBUG: Channel: Sent CLOSE\r\nDEBUG: Channel: Sent CHANNEL_DATA\r\nDEBUG: Channel: Sent CHANNEL_DATA\r\nDEBUG: Parser: STATE_PACKETBEFORE (expecting 16)\r\nDEBUG: Parser: STATE_PACKET\r\nDEBUG: Parser: Decrypting\r\nDEBUG: Parser: pktLen:12,padLen:6,remainLen:0\r\nDEBUG: Parser: STATE_PACKETDATA\r\nDEBUG: Parser: hmacSize:16\r\nDEBUG: Parser: STATE_PACKETDATAVERIFY\r\nDEBUG: Parser: Verifying MAC\r\nDEBUG: Parser: STATE_PACKETDATAAFTER, packet: CHANNEL_EOF\r\nDEBUG: Parser: STATE_PACKETBEFORE (expecting 16)\r\nDEBUG: Parser: STATE_PACKET\r\nDEBUG: Parser: Decrypting\r\nDEBUG: Parser: pktLen:12,padLen:6,remainLen:0\r\nDEBUG: Parser: STATE_PACKETDATA\r\nDEBUG: Parser: hmacSize:16\r\nDEBUG: Parser: STATE_PACKETDATAVERIFY\r\nDEBUG: Parser: Verifying MAC\r\nDEBUG: Parser: STATE_PACKETDATAAFTER, packet: CHANNEL_CLOSE\r\nDEBUG: Parser: STATE_PACKETBEFORE (expecting 16)\r\nDEBUG: Parser: STATE_PACKETBEFORE (expecting 16)\r\nDEBUG: Connection: Sending DISCONNECT\r\nDEBUG: Channel: Sent EOF\r\nDEBUG: Channel: Sent EOF\r\n```\r\n\r\nHere is the code:\r\n\r\n```javascript\r\nvar Connection = require('ssh2');\r\n\r\nvar conn1 = new Connection(),\r\n    conn2 = new Connection();\r\n\r\nconn1.on('ready', function() {\r\n  console.log('FIRST :: connection ready');\r\n  conn1.exec('nc 192.168.1.2 22903', function(err, stream) {\r\n    if (err) {\r\n      console.log('FIRST :: exec error: ' + err);\r\n      return conn1.end();\r\n    }\r\n    conn2.connect({\r\n      sock: stream,\r\n      username: 'root',\r\n      agent: process.env.SSH_AUTH_SOCK,\r\n      agentForward: true,\r\n      debug: console.log\r\n    });\r\n  });\r\n}).connect({\r\n        host: 'theip',\r\n        username: 'theuser',\r\n        port: 123,\r\n        privateKey: require('fs').readFileSync(''),\r\n        passphrase: 'passphrase',\r\n        debug: console.log\r\n    });\r\n\r\nconn2.on('ready', function() {\r\n  console.log('SECOND :: connection ready');\r\n  conn2.exec([\r\n      'cd /home/',\r\n      'git pull Github Production'\r\n    ].join(' && '), function(err, stream) {\r\n    if (err) {\r\n      console.log('SECOND :: exec error: ' + err);\r\n      return conn1.end();\r\n    }\r\n    stream.on('end', function() {\r\n      conn1.end(); // close parent (and this) connection\r\n    }).on('data', function(data) {\r\n      console.log(data.toString());\r\n    });\r\n  });\r\n});\r\n```"}}