Monday, 3 April 2017

Unhandled error in node.js

    app.get('/api/platforms2',function(req,res){
    var sshcommectionresult="came";
    c.connect({
      host: '10.254.27.9',
      port: 22,
       //debug: console.log,
       readyTimeout: 99999,
      username: 'bwadminwww',
      password:'bwadmiqqn1w' 
    });

    c.on('connect', function() {
      console.log('Connection :: connect');
    });
    c.on('ready', function() {
      console.log('Connection :: ready');
        sshcommectionresult="Connected";

            c.on('error', function(err) {

                console.log('Connection :: error :: ' + err);
                sys.debug("Unable to login");
                sshcommectionresult=err;
            });
    c.on('end', function() {
      console.log('Connection :: end');

    });
    c.on('close', function(had_error) {
      console.log('Connection :: close');
    });
        res.json(sshcommectionresult);
    });
    });

//If i am having correct username and password it is getting connected.But if i giving wrong username and password.It is showing unhandled error.I am not able to fix this.



via vinay

No comments:

Post a Comment