Skip to content

Connection fails when secure event is bound. #241

Closed

Description

@tracker1

Not sure about SQL Server, but at least with Azure, when you bind to the secure event, the connection will fail.

This is with the patch #240 and relates to #238.

I'm filing this as a separate issue, because the PR allows the connection to happen without the secure event.

test.js

// node test.js > log.txt 2>&1

var clone = require('safe-clone-deep');

var Connection = require('tedious').Connection;

var config = {
  userName: 'user@dbserv',
  password: 'password',
  server: 'dbserv.database.secure.windows.net',

  options: {
    database: 'dbname'
    ,encrypt: true
    ,useUTC: true
    ,connectTimeout: 10000
    ,debug:{
      packet:true
      ,data:true
      ,payload:true
      ,token:true
    }
  }
};


function show(event) {
  return function(data){
    console.log(event);
    return;

    var txt = data && JSON.stringify(clone(data));
    if (txt.length > 1024) {
      console.error(event + ': ' + txt.substr(0,1024));
    } else {
      console.error(event + ': ' + txt);
    }
  }
}

var connection = new Connection(config);

function show(event) {
  return function(data){
    console.error(event + ': ' + JSON.stringify(clone(data)));
  }
}

var connection = new Connection(config);

connection.on('debug',function(message){
  if (!message) return;
  console.error("DEBUG: " + message);
});

connection.on('connect', function(err){
  console.error('connected');
  process.exit(0);
});
connection.on('end',show('end'));
connection.on('error', show('error'));
connection.on('infoMessage',show('infoMessage'));
connection.on('errorMessage',show('errorMessage'));
connection.on('databaseChange',show('databaseChange'));

// if this line is uncommented, it will not connect properly
//connection.on('secure',show('secure'));

setTimeout(process.exit.bind(process,666),10000); //timeout, nuclear option

Activity

  1. tracker1 commented on Feb 11, 2015

    @tracker1
    ContributorAuthor

    When I use...

    connection.on('secure',function(){
      console.log('secure');
      console.log(arguments);
    });

    It's probably an issue with my clone command, and the buffer, which is relatively huge... causing a timeout during clone/serialization/output... non-issue, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions