Skip to content

Commit

Permalink
Merge pull request #538 from tvrprasad/node-7.7.2-socket-connect-fix
Browse files Browse the repository at this point in the history
Work-around socket.connect bug in Node 7.7.2
  • Loading branch information
tvrprasad authored Mar 10, 2017
2 parents fba751f + b7adbea commit ba01a85
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Request = require('./request');
const RpcRequestPayload = require('./rpcrequest-payload');
const SqlBatchPayload = require('./sqlbatch-payload');
const MessageIO = require('./message-io');
const Socket = require('net').Socket;
const net = require('net');
const TokenStreamParser = require('./token/token-stream-parser').Parser;
const Transaction = require('./transaction').Transaction;
const ISOLATION_LEVEL = require('./transaction').ISOLATION_LEVEL;
Expand Down Expand Up @@ -508,15 +508,14 @@ class Connection extends EventEmitter {
}

connectOnPort(port) {
this.socket = new Socket({});
const connectOpts = {
host: this.routingData ? this.routingData.server : this.config.server,
port: this.routingData ? this.routingData.port : port
};
if (this.config.options.localAddress) {
connectOpts.localAddress = this.config.options.localAddress;
}
this.socket.connect(connectOpts);
this.socket = net.connect(connectOpts);
this.socket.on('error', this.socketError);
this.socket.on('connect', this.socketConnect);
this.socket.on('close', this.socketClose);
Expand Down

0 comments on commit ba01a85

Please sign in to comment.