Fixed connection for 0.11 and older versions
Fixes #122. node-0.11 changes how TLS connections handle sockets when connecting. Discovered in #65, it's necessary to attach the error handler before the socket establishes a connection. In some cases the socket errors before the TLS#connect method returns, so the error handler hasn't been attached yet and an exception is raised.
This commit is contained in:
Родитель
ef13e4446d
Коммит
68de3b9661
|
@ -211,7 +211,12 @@ Connection.prototype.connect = function () {
|
|||
|
||||
// The actual connection is delayed until after all the event listeners have
|
||||
// been attached.
|
||||
this.socket.connect(this.options['port'], this.options['gateway']);
|
||||
if ("function" == typeof this.socket.connect ) {
|
||||
this.socket.connect(this.options['port'], this.options['gateway']);
|
||||
}
|
||||
else {
|
||||
socketOptions.socket.connect(this.options['port'], this.options['gateway']);
|
||||
}
|
||||
}.bind(this)).fail(function (error) {
|
||||
debug("Module initialisation error:", error);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче