它只是发送关闭原因,我将保持活动时间设置为40分钟,这是我的配置:
"use strict";
require("dotenv").config();
const mosca = require("mosca");
const logger = require("./lib/utils/logger");
const config = require("./lib/config");
const events = require("./lib/events");
const ip = require("ip");
let pub_settings = {
type : config.PUB_TYPE,
db : config.PUB_DB,
port : config.PUB_PORT,
return_buffers: config.RETURN_BUFFERS,
host : config.PUB_HOST
};
let mosca_settings = {
id : ip.address(),
host : config.MOSCA_HOST,
port : config.MOSCA_PORT,
backend : pub_settings,
persistence: {
factory: mosca.persistence.Redis,
port : config.MOSCA_PERSISTENCE_PORT,
host : config.MOSCA_PERSISTENCE_HOST,
ttl : {
subscriptions: 1000 * 60 * 60 * 24 * 30,
packets : 1000 * 60 * 60 * 24 * 7
}
},
stats : true
};
let server = new mosca.Server(mosca_settings);
events(server);
logger.info("Server ID: "+server.id);
logger.info("Server running at: mqtt://"+ config.MOSCA_HOST + ":" + config.MOSCA_PORT);
process.on("SIGINT", function () {
//logger.info('Starting server shutdown');
server.close(function () {
process.exit(0);
});
});
module.exports = server;
10分钟后,客户端仅显示“关闭”消息而断开连接。
我有45分钟的保活期,当减少时,它会与消息“ keepaliveTimeout”断开连接。