events.EventEmitter.call(this);
if (ssl) {
- this.socket = tls.connect({host: hostname, port: port, rejectUnauthorized: global.config.reject_unauthorised_certificates}, connect_handler);
+ this.socket = tls.connect({
+ host: hostname,
+ port: port,
+ rejectUnauthorized: global.config.reject_unauthorised_certificates
+ }, function () {
+ connect_handler.apply(that, arguments);
+ });
} else {
this.socket = net.createConnection(port, hostname);
this.socket.on('connect', function () {