From b86fedc3050d047f06365fba883fac042db89ae6 Mon Sep 17 00:00:00 2001 From: danghongquan Date: Fri, 11 Apr 2025 13:52:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=89=A9=E5=B1=95=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=9C=A8=E7=AB=AF=E5=8F=A3=E5=8D=A0=E7=94=A8=E6=97=B6=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: danghongquan --- app.js | 13 ++++++++----- version.js | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index 46e7db5..6b5ad4c 100644 --- a/app.js +++ b/app.js @@ -17,10 +17,16 @@ const winston = require('winston'); const SessionManage = require('./session.js'); const Utils = require('./Util.js'); const TypeManage = require('./typeManage.js'); -const wss = new WebSocket.Server({ port: `${Utils.AuthMsg.SW_PORT}`, maxPayload: 1024 * 1024 * 500 }); // 创建logger const logger = winston.createLogger(require('./winston.config.js')); - +const wss = new WebSocket.Server({ port: `${Utils.AuthMsg.SW_PORT}`, maxPayload: 1024 * 1024 * 500 }); +// 当发生错误时触发 +wss.on('error', function error(err) { + if (err.code === 'EADDRINUSE') { + logger.error(`Port ${Utils.AuthMsg.SW_PORT} is occupied`); + } + logger.error(`Connection error:${err}`); +}); // 当有新客户端连接时触发 wss.on('connection', function connection(ws) { // WebSocket的一个属性,用于控制 WebSocket 连接如何处理接收到的二进制数据; @@ -88,9 +94,6 @@ wss.on('connection', function connection(ws) { // 当发生错误时触发 ws.on('error', function error(err) { - if(err.code === 'EADDRINUSE') { - logger.err(`Port ${Utils.AuthMsg.SW_PORT} is occupied`); - } logger.error(`Connection error:${err}`); }); }) diff --git a/version.js b/version.js index b67bf7a..332c9cc 100644 --- a/version.js +++ b/version.js @@ -13,7 +13,7 @@ * limitations under the License. */ class version { - static version = '1.1.1'; //版本号 + static version = '1.1.2'; //版本号 } module.exports = { -- Gitee