mirror of
https://github.com/chirpstack/chirpstack.git
synced 2024-12-22 06:27:49 +00:00
Add keep_alive_interval config for MQTT.
In case there is a loadbalancer between ChirpStack and the MQTT broker, it is useful to have control over the keep-alive messages, to make sure that the loadbalancer does not drop the connection if there is no activity. In such a case you want to set the keep_alive_interval to a lower interval than the loadbalancer timeout.
This commit is contained in:
parent
3a6e359ce1
commit
948ed00b60
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -66,6 +66,12 @@
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id=""
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="30s"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -351,6 +351,12 @@ pub fn run() {
|
||||
# a random id will be generated by ChirpStack.
|
||||
client_id="{{ integration.mqtt.client_id }}"
|
||||
|
||||
# Keep alive interval.
|
||||
#
|
||||
# This defines the maximum time that that should pass without communication
|
||||
# between the client and server.
|
||||
keep_alive_interval="{{ integration.mqtt.keep_alive_interval }}"
|
||||
|
||||
# CA certificate file (optional)
|
||||
#
|
||||
# Use this when setting up a secure connection (when server uses ssl://...)
|
||||
|
@ -270,6 +270,8 @@ pub struct MqttIntegration {
|
||||
pub ca_cert: String,
|
||||
pub tls_cert: String,
|
||||
pub tls_key: String,
|
||||
#[serde(with = "humantime_serde")]
|
||||
pub keep_alive_interval: Duration,
|
||||
}
|
||||
|
||||
impl Default for MqttIntegration {
|
||||
@ -289,6 +291,7 @@ impl Default for MqttIntegration {
|
||||
ca_cert: "".into(),
|
||||
tls_cert: "".into(),
|
||||
tls_key: "".into(),
|
||||
keep_alive_interval: Duration::from_secs(30),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -537,8 +540,6 @@ impl Default for Region {
|
||||
event_topic: "eu868/gateway/+/event/+".into(),
|
||||
command_topic: "eu868/gateway/{{ gateway_id }}/command/{{ command }}"
|
||||
.into(),
|
||||
server: "tcp://127.0.0.1:1883".into(),
|
||||
clean_session: false,
|
||||
..Default::default()
|
||||
},
|
||||
},
|
||||
@ -612,7 +613,7 @@ pub struct GatewayBackend {
|
||||
pub mqtt: GatewayBackendMqtt,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone)]
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[serde(default)]
|
||||
pub struct GatewayBackendMqtt {
|
||||
pub event_topic: String,
|
||||
@ -626,6 +627,27 @@ pub struct GatewayBackendMqtt {
|
||||
pub ca_cert: String,
|
||||
pub tls_cert: String,
|
||||
pub tls_key: String,
|
||||
#[serde(with = "humantime_serde")]
|
||||
pub keep_alive_interval: Duration,
|
||||
}
|
||||
|
||||
impl Default for GatewayBackendMqtt {
|
||||
fn default() -> Self {
|
||||
GatewayBackendMqtt {
|
||||
event_topic: "".into(),
|
||||
command_topic: "".into(),
|
||||
server: "tcp://127.0.0.1:1883/".into(),
|
||||
username: "".into(),
|
||||
password: "".into(),
|
||||
qos: 0,
|
||||
clean_session: false,
|
||||
client_id: "".into(),
|
||||
ca_cert: "".into(),
|
||||
tls_cert: "".into(),
|
||||
tls_key: "".into(),
|
||||
keep_alive_interval: Duration::from_secs(30),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Hash)]
|
||||
|
@ -143,6 +143,7 @@ impl<'a> MqttBackend<'a> {
|
||||
let mut conn_opts_b = mqtt::ConnectOptionsBuilder::new();
|
||||
conn_opts_b.automatic_reconnect(Duration::from_secs(1), Duration::from_secs(30));
|
||||
conn_opts_b.clean_session(conf.clean_session);
|
||||
conn_opts_b.keep_alive_interval(conf.keep_alive_interval);
|
||||
conn_opts_b.user_name(&conf.username);
|
||||
conn_opts_b.password(&conf.password);
|
||||
if !conf.ca_cert.is_empty() || !conf.tls_cert.is_empty() || !conf.tls_key.is_empty() {
|
||||
|
@ -99,6 +99,7 @@ impl<'a> Integration<'a> {
|
||||
let mut conn_opts_b = mqtt::ConnectOptionsBuilder::new();
|
||||
conn_opts_b.automatic_reconnect(Duration::from_secs(1), Duration::from_secs(30));
|
||||
conn_opts_b.clean_session(conf.clean_session);
|
||||
conn_opts_b.keep_alive_interval(conf.keep_alive_interval);
|
||||
conn_opts_b.user_name(&conf.username);
|
||||
conn_opts_b.password(&conf.password);
|
||||
if !conf.ca_cert.is_empty() || !conf.tls_cert.is_empty() || !conf.tls_key.is_empty() {
|
||||
|
Loading…
Reference in New Issue
Block a user