From fbfe8cbda06e928e8d7cf33b56bfff7090d5884c Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 19 Jul 2022 00:27:54 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=88=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B1=D0=BB=D0=B5=D0=BC=D1=8B=20=D0=BD=D0=B5?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=BD=D0=BE=D0=B3=D0=BE=20tls-?= =?UTF-8?q?=D1=81=D0=B5=D1=80=D1=82=D0=B8=D1=84=D0=B8=D0=BA=D0=B0=D1=82?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/RemoteStorage.js | 2 +- server/core/WebSocketConnection.js | 9 ++++++--- server/index.js | 1 - 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/server/core/RemoteStorage.js b/server/core/RemoteStorage.js index 9af5a13d..ae2bbb4f 100644 --- a/server/core/RemoteStorage.js +++ b/server/core/RemoteStorage.js @@ -10,7 +10,7 @@ class RemoteStorage { this.accessToken = this.config.accessToken; - this.wsc = new WebSocketConnection(config.url); + this.wsc = new WebSocketConnection(config.url, 10, 30, {rejectUnauthorized: false}); } async wsRequest(query) { diff --git a/server/core/WebSocketConnection.js b/server/core/WebSocketConnection.js index fcdbcd1e..12fa4f9e 100644 --- a/server/core/WebSocketConnection.js +++ b/server/core/WebSocketConnection.js @@ -8,10 +8,13 @@ const cleanPeriod = 5*1000;//5 секунд class WebSocketConnection { //messageLifeTime в секундах (проверка каждый cleanPeriod интервал) - constructor(url, openTimeoutSecs = 10, messageLifeTimeSecs = 30) { + constructor(url, openTimeoutSecs = 10, messageLifeTimeSecs = 30, webSocketOptions = {}) { this.WebSocket = (isBrowser ? WebSocket : require('ws')); this.url = url; + this.webSocketOptions = webSocketOptions; + this.ws = null; + this.listeners = []; this.messageQueue = []; this.messageLifeTime = messageLifeTimeSecs*1000; @@ -89,9 +92,9 @@ class WebSocketConnection { if (isBrowser) { const protocol = (window.location.protocol == 'https:' ? 'wss:' : 'ws:'); const url = this.url || `${protocol}//${window.location.host}/ws`; - this.ws = new this.WebSocket(url); + this.ws = new this.WebSocket(url, this.webSocketOptions); } else { - this.ws = new this.WebSocket(this.url); + this.ws = new this.WebSocket(this.url, this.webSocketOptions); } const onopen = () => { diff --git a/server/index.js b/server/index.js index c9ed4235..6cf90267 100644 --- a/server/index.js +++ b/server/index.js @@ -1,5 +1,4 @@ require('tls').DEFAULT_MIN_VERSION = 'TLSv1'; -process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0; const fs = require('fs-extra'); const argv = require('minimist')(process.argv.slice(2));