transports: set handshake timeout of ws to 10s

This commit is contained in:
Micooz 2018-06-15 10:33:28 +08:00
parent 6da3708cb9
commit 138636da69
2 changed files with 8 additions and 2 deletions

@ -71,7 +71,10 @@ class WsOutbound extends _tcp.TcpOutbound {
async _connect(target) {
const address = this.getConnAddress(target);
_utils.logger.info(`[${this.name}] [${this.remote}] connecting to ${address}`);
const socket = new _ws2.default(address, this.getConnOptions({ perMessageDeflate: false }));
const socket = new _ws2.default(address, this.getConnOptions({
handshakeTimeout: 1e4,
perMessageDeflate: false
}));
socket.on('message', this.onReceive);
socket.on('close', () => socket.destroyed = true);
return patchWebsocket.call(this, socket);

@ -60,7 +60,10 @@ export class WsOutbound extends TcpOutbound {
async _connect(target) {
const address = this.getConnAddress(target);
logger.info(`[${this.name}] [${this.remote}] connecting to ${address}`);
const socket = new WebSocket(address, this.getConnOptions({ perMessageDeflate: false }));
const socket = new WebSocket(address, this.getConnOptions({
handshakeTimeout: 1e4, // 10s
perMessageDeflate: false,
}));
socket.on('message', this.onReceive);
socket.on('close', () => socket.destroyed = true);
return patchWebsocket.call(this, socket);