title: node js:Not able to catch 'error' in ssh2 connection on MacOSx/Linux
body: <pre><code>this.connection = new Connection(); //ssh2 connection
          async.waterfall([function(callback) {
              // some initialization code to connect
              }
          }], function(err, opts) {
              if (err) {
                  callback({
                      message: 'Error during connecting to the device...',
                      detail: err
                  }, false);
              } else {
                  console.log('Connecting to ... ' + JSON.stringify(self.info));
                  self.connection.on('ready', function() {
                      console.info('Connected... opening a shell...');
                      callback(null, true);
                  }).on('error', function(err) {
                      console.error('Error during connecting to the device: ' + err);
                      callback({
                          message: 'Error during connecting to the device...',
                          detail: err
                      }, false);
                  }).on('end', function() {
                      console.info("Connection ended...");
                  }).on('close', function(hadError) {
                      console.info("Connection closed..." + (hadError ? " with error" : ""));
                  }).connect(opts);
              }
          });
  </code></pre>
  
  <p>Referring to the above code, I am connecting to a device using an ssh2 connection, everything works fine..I am getting console logs for on 'ready', on 'close' ,etc but not able to get the console logs when an on 'error' occurs.</p>
  
  <p>I can capture the on 'error'event on win7 32 bit but not on MacOSx(10.9.5) or on Linux(Ubuntu 12). The on 'error' event is triggered when I forcefully end the connection to the device(say plug out the lan cable from my system). </p>
  
  <p>Is this some limitation on Mac/Linux w.r.t the ssh2 module or is it that I am doing something wrong in the way to capture an error.</p>
  
  <p>Any pointers will be really helpful.</p>
  
  <p>node js version v0.10.29
  ssh2 version v0.4.8</p>