improve mqtt

This commit is contained in:
csehviktor
2025-07-03 06:09:09 +02:00
parent dbbc673efe
commit 58a4ab9974
4 changed files with 115 additions and 0 deletions

19
server/mqtt.toml Normal file
View File

@@ -0,0 +1,19 @@
id = 0
[router]
id = 0
max_connections = 10010
max_outgoing_packet_count = 200
max_segment_size = 104857600
max_segment_count = 10
[v4.1]
name = "v4-1"
listen = "0.0.0.0:1883"
next_connection_delay_ms = 1
[v4.1.connections]
connection_timeout_ms = 60000
max_payload_size = 20480
max_inflight_count = 100
dynamic_filters = true

14
server/src/config.rs Normal file
View File

@@ -0,0 +1,14 @@
use rumqttd::Config;
const BROKER_CONFIG_PATH: &str = if cfg!(debug_assertions) {
"server/mqtt.toml"
} else {
"mqtt.toml"
};
pub fn load_broker_config() -> anyhow::Result<Config> {
let content = std::fs::read_to_string(BROKER_CONFIG_PATH)?;
let config: Config = toml::from_str(&content)?;
Ok(config)
}