diff --git a/app.js b/app.js index 46e7db509db8798d5da047fc639e0135aec0b258..6b5ad4c92ac33cfd8ac524cd5fb6271ab356f319 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 b67bf7a43daeb1ec9de6d0414fd30586c16b3b3a..332c9cc622f596941b72a58f0ed1f389569d130a 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 = {