allow-modify-mqtt-port

This commit is contained in:
Eason010212
2024-03-12 22:49:53 +08:00
parent 8795e3114f
commit f55dbc173a
7 changed files with 80 additions and 27 deletions

View File

@@ -17,27 +17,33 @@
---
## 主站(免费使用)
https://mixio.mixly.cn
## 私有部署发行版-v1.10.1
### Windows-x64发行版win10及以上
https://gitee.com/bnu_mixly/mixio-win32-x86-dist/blob/master/mixio.exe
### Windows-x64发行版win7
https://gitee.com/bnu_mixly/mixio-win32-x86-dist/blob/win7/mixio.exe
### Linux-x64发行版
https://gitee.com/bnu_mixly/mixio-linux-x86-dist/blob/master/mixio
### Linux-arm64发行版
https://gitee.com/bnu_mixly/mixio-linux-arm64-dist/blob/master/mixio
### MacOS-x64发行版
https://gitee.com/bnu_mixly/mixio-linux-x86-dist/blob/darwin/mixio
## 指令说明
1. mixio start 启动服务器默认在8080端口
2. mixio stop 关闭服务器
3. mixio help 查看更多指令
@@ -45,14 +51,17 @@ https://gitee.com/bnu_mixly/mixio-linux-x86-dist/blob/darwin/mixio
5. Linux/MacOS版 可mixio install将mixio添加到systemctl中
## 从源码运行debug模式
1. git clone https://gitee.com/mixly2/mixio.git
2. node mixio.js debug
## 从源码构建
1. 编译脚本见pkg_tools/
2. 基本环境node16(windows7为node12), python3, cmake, pkg.
## 安卓端运行服务器experimental
1. 安装termuxhttps://termux.dev/en/
2. apt update
3. apt upgrade
@@ -66,24 +75,28 @@ https://gitee.com/bnu_mixly/mixio-linux-x86-dist/blob/darwin/mixio
11. node mixio.js debug
## 服务器配置文件config/config.json
1. 首次运行服务器后会在相对应位置的config文件夹生成config.json
2. config.json内容可修改重启服务器后生效
3. MIXIO_HTTP_PORT - intHTTP端口默认为8080
4. MIXIO_HTTPS_PORT - intHTTP端口默认为8443
5. MAX_PROJECT_NUM_PER_USER - int每个用户的最大项目数默认为20
6. MAX_MESSAGE_PER_USER - int每个用户的最大离线消息存储数默认为1000
7. MAX_MESSAGE_PER_SECOND - int每个用户每秒的最大消息数默认为5
8. ALLOW_REGISTER - bool是否允许自主注册默认为true
9. ALLOW_HOOK - bool是否允许离线存储消息默认为true
10. OFFLINE_MODE - bool是否禁用天气/地图数据默认为true
11. BAIDU_MAP_AK - string百度地图客户端应用AKOFFLINE_MODE=false时必须配置默认为""
12. BAIDU_MAP_SERVER_AK - string百度地图服务端应用AKOFFLINE_MODE=false时必须配置默认为""
13. ADMIN_USERNAME - string管理后台用户名默认为"admin"
14. ADMIN_PASSWORD - string管理后台密码默认为"public"
15. STORAGE_ENGINE - string数据库引擎默认为"sqlite"
16. MYSQL_HOST - stringMySQL地址STORAGE_ENGINE="mysql"时必须配置),默认为"localhost"
17. MYSQL_PORT - intMySQL地址STORAGE_ENGINE="mysql"时必须配置默认为3306
18. MYSQL_USER - stringMySQL用户名STORAGE_ENGINE="mysql"时必须配置),默认为""
19. MYSQL_PASS - stringMySQL密码STORAGE_ENGINE="mysql"时必须配置),默认为""
20. MYSQL_DB - stringMySQL数据库名STORAGE_ENGINE="mysql"时必须配置),默认为"mixio",
21. FOOTER - string显示在首页的备案信息公网部署时请务必配置此项支持HTML语言请注意为双引号添加转义字符\\),默认为""
5. MIXIO_MQTT_PORT - int, MQTT端口, 默认为1883
6. MIXIO_WS_PORT - int, MQTT over WebSocket端口, 默认为8083
7. MIXIO_WSS_PORT - int, MQTT over WebSocketS端口, 默认为8084
8. MAX_PROJECT_NUM_PER_USER - int每个用户的最大项目数默认为20
9. MAX_MESSAGE_PER_USER - int每个用户的最大离线消息存储数默认为1000
10. MAX_MESSAGE_PER_SECOND - int每个用户每秒的最大消息数默认为5
11. ALLOW_REGISTER - bool是否允许自主注册默认为true
12. ALLOW_HOOK - bool是否允许离线存储消息默认为true
13. OFFLINE_MODE - bool是否禁用天气/地图数据默认为true
14. BAIDU_MAP_AK - string百度地图客户端应用AKOFFLINE_MODE=false时必须配置默认为""
15. BAIDU_MAP_SERVER_AK - string百度地图服务端应用AKOFFLINE_MODE=false时必须配置默认为""
16. ADMIN_USERNAME - string管理后台用户名默认为"admin"
17. ADMIN_PASSWORD - string管理后台密码默认为"public"
18. STORAGE_ENGINE - string数据库引擎默认为"sqlite"
19. MYSQL_HOST - stringMySQL地址STORAGE_ENGINE="mysql"时必须配置),默认为"localhost"
20. MYSQL_PORT - intMySQL地址STORAGE_ENGINE="mysql"时必须配置),默认为3306
21. MYSQL_USER - stringMySQL用户名STORAGE_ENGINE="mysql"时必须配置),默认为""
22. MYSQL_PASS - stringMySQL密码STORAGE_ENGINE="mysql"时必须配置),默认为""
23. MYSQL_DB - stringMySQL数据库名STORAGE_ENGINE="mysql"时必须配置),默认为"mixio",
24. FOOTER - string显示在首页的备案信息公网部署时请务必配置此项支持HTML语言请注意为双引号添加转义字符\\),默认为""

View File

@@ -183,6 +183,30 @@
<input type="number" id="MIXIO_HTTPS_PORT">
</td>
</tr>
<tr>
<td>
<span>MQTT 端口:</span>
</td>
<td>
<input type="number" id="MIXIO_MQTT_PORT">
</td>
</tr>
<tr>
<td>
<span>WS 端口:</span>
</td>
<td>
<input type="number" id="MIXIO_WS_PORT">
</td>
</tr>
<tr>
<td>
<span>WSS 端口:</span>
</td>
<td>
<input type="number" id="MIXIO_WSS_PORT">
</td>
</tr>
<tr>
<td>
<span>SSL证书私钥</span>
@@ -322,6 +346,9 @@
}, 1000);
var MIXIO_HTTP_PORT = "<%=configs["MIXIO_HTTP_PORT"]%>"
var MIXIO_HTTPS_PORT = "<%=configs["MIXIO_HTTPS_PORT"]%>"
var MIXIO_MQTT_PORT = "<%=configs["MIXIO_MQTT_PORT"]%>"
var MIXIO_WS_PORT = "<%=configs["MIXIO_WS_PORT"]%>"
var MIXIO_WSS_PORT = "<%=configs["MIXIO_WSS_PORT"]%>"
var HTTPS_PRIVATE_PEM = "<%=configs["HTTPS_PRIVATE_PEM"]%>"
var HTTPS_CRT_FILE = "<%=configs["HTTPS_CRT_FILE"]%>"
var MAX_PROJECT_NUM_PER_USER = "<%=configs["MAX_PROJECT_NUM_PER_USER"]%>"
@@ -349,6 +376,9 @@
var loadConfig = function(){
$("#MIXIO_HTTP_PORT").val(MIXIO_HTTP_PORT)
$("#MIXIO_HTTPS_PORT").val(MIXIO_HTTPS_PORT)
$("#MIXIO_MQTT_PORT").val(MIXIO_MQTT_PORT)
$("#MIXIO_WS_PORT").val(MIXIO_WS_PORT)
$("#MIXIO_WSS_PORT").val(MIXIO_WSS_PORT)
$("#HTTPS_PRIVATE_PEM").val(HTTPS_PRIVATE_PEM)
$("#HTTPS_CRT_FILE").val(HTTPS_CRT_FILE)
$("#ALLOW_REGISTER").prop("checked",ALLOW_REGISTER)
@@ -380,6 +410,9 @@
configs = {}
configs["MIXIO_HTTP_PORT"] = parseInt($("#MIXIO_HTTP_PORT").val())
configs["MIXIO_HTTPS_PORT"] = parseInt($("#MIXIO_HTTPS_PORT").val())
configs["MIXIO_MQTT_PORT"] = parseInt($("#MIXIO_MQTT_PORT").val())
configs["MIXIO_WS_PORT"] = parseInt($("#MIXIO_WS_PORT").val())
configs["MIXIO_WSS_PORT"] = parseInt($("#MIXIO_WSS_PORT").val())
configs["HTTPS_PRIVATE_PEM"] = $("#HTTPS_PRIVATE_PEM").val()
configs["HTTPS_CRT_FILE"] = $("#HTTPS_CRT_FILE").val()
configs["MAX_PROJECT_NUM_PER_USER"] = parseInt($("#MAX_PROJECT_NUM_PER_USER").val())

View File

@@ -36,6 +36,8 @@
<script src="js/widgets.js"></script>
<script>var OFFLINE_MODE = <%=configs['OFFLINE_MODE']%></script>
<script>var BAIDU_MAP_AK = '<%=configs['BAIDU_MAP_AK']%>'</script>
<script>var MIXIO_WS_PORT = '<%=configs['MIXIO_WS_PORT']%>'</script>
<script>var MIXIO_WSS_PORT = '<%=configs['MIXIO_WSS_PORT']%>'</script>
<script src="js/MixIO.js?v=4"></script>
<script src="js/observe.js?v=10"></script>
</head>

View File

@@ -46,6 +46,8 @@
<script>var OFFLINE_MODE = <%=configs['OFFLINE_MODE']%></script>
<script>var MAX_PROJECT_NUM_PER_USER = <%=configs['MAX_PROJECT_NUM_PER_USER']%></script>
<script>var BAIDU_MAP_AK = '<%=configs['BAIDU_MAP_AK']%>'</script>
<script>var MIXIO_WS_PORT = '<%=configs['MIXIO_WS_PORT']%>'</script>
<script>var MIXIO_WSS_PORT = '<%=configs['MIXIO_WSS_PORT']%>'</script>
<script src="js/projects.js?v=273"></script>
<script src="js/MixIO.js?v=30"></script>
<style>

View File

@@ -48,7 +48,7 @@ $(function(){
randomClientID = 'OBGuest_' + Math.random().toString(16).substr(2, 8)
globalUserName = userName
globalProjectName = projectName
client = mqtt.connect((location.protocol == 'https:' ? 'wss://' : 'ws://')+window.location.host+(location.protocol == 'https:' ? ':8084' : ':8083')+'/mqtt',{
mqtt.connect((location.protocol == 'https:' ? 'wss://' : 'ws://') + window.location.host.split(":")[0] + (location.protocol == 'https:' ? (':'+MIXIO_WSS_PORT) : (':'+MIXIO_WS_PORT)), {
'clientId':randomClientID,
'username':userName,
'password':projectPass

View File

@@ -847,7 +847,7 @@ function view_project(projectName, projectType) {
keyName = userName.slice(1)
userName = 'MixIO_public'
}
client = mqtt.connect((location.protocol == 'https:' ? 'wss://' : 'ws://') + window.location.host.split(":")[0] + (location.protocol == 'https:' ? ':8084' : ':8083'), {
client = mqtt.connect((location.protocol == 'https:' ? 'wss://' : 'ws://') + window.location.host.split(":")[0] + (location.protocol == 'https:' ? (':'+MIXIO_WSS_PORT) : (':'+MIXIO_WS_PORT)), {
'clientId': randomClientID,
'username': userName,
'password': projectPass,

View File

@@ -53,6 +53,9 @@ function init(cb){
var defaultConfig = `{
"MIXIO_HTTP_PORT": 8080,
"MIXIO_HTTPS_PORT": 8443,
"MIXIO_MQTT_PORT": 1883,
"MIXIO_WS_PORT": 8083,
"MIXIO_WSS_PORT": 8084,
"MAX_PROJECT_NUM_PER_USER": 20,
"MAX_MESSAGE_PER_USER": 1000,
"MAX_MESSAGE_PER_SECOND": 5,
@@ -1939,12 +1942,12 @@ var mixioServer = function() {
}
return new Promise(resolve => {
plainServer.listen(1883, function() {
console.log('[INFO] Plain MQTT server listening on port', 1883)
httpServer.listen(8083, function() {
console.log('[INFO] WebSocket MQTT server listening on port', 8083)
httpsServer.listen(8084, function() {
console.log('[INFO] WebSocketS MQTT server listening on port', 8084)
plainServer.listen(configs["MIXIO_MQTT_PORT"], function() {
console.log('[INFO] Plain MQTT server listening on port', configs["MIXIO_MQTT_PORT"])
httpServer.listen(configs["MIXIO_WS_PORT"], function() {
console.log('[INFO] WebSocket MQTT server listening on port', configs["MIXIO_WS_PORT"])
httpsServer.listen(configs["MIXIO_WSS_PORT"], function() {
console.log('[INFO] WebSocketS MQTT server listening on port', configs["MIXIO_WSS_PORT"])
httpServer2 = http.createServer(app)
httpServer2.listen(configs['MIXIO_HTTP_PORT'], function() {
if(configs['MIXIO_HTTP_PORT'] != 0)
@@ -2447,7 +2450,7 @@ var MixIOclosure = function(userName, projectName, projectPass, dataStorage, dom
}
this.lastPublishTime = [new Date(0), new Date(0), new Date(0), new Date(0), new Date(0), new Date(0), new Date(0), new Date(0), new Date(0), new Date(0), new Date(0), new Date(0), new Date(0), new Date(0), new Date(0), new Date(0), new Date(0), new Date(0), new Date(0), new Date(0)],
this.minPublishInterval = 500,
this.client = mqtt.connect('ws://localhost:8083', {
this.client = mqtt.connect('ws://localhost:' + configs["MIXIO_WS_PORT"], {
'clientId': "MixIO_" + Math.random().toString(16).substr(2, 8),
'username': userName,
'password': projectPass