From 948ed00b608b61a67475f516765a4c39addf6236 Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Fri, 25 Nov 2022 12:51:35 +0000 Subject: [PATCH] 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. --- chirpstack/configuration/region_as923.toml | 6 ++++ chirpstack/configuration/region_as923_2.toml | 6 ++++ chirpstack/configuration/region_as923_3.toml | 6 ++++ chirpstack/configuration/region_as923_4.toml | 6 ++++ chirpstack/configuration/region_au915_0.toml | 6 ++++ chirpstack/configuration/region_au915_1.toml | 6 ++++ chirpstack/configuration/region_au915_2.toml | 6 ++++ chirpstack/configuration/region_au915_3.toml | 6 ++++ chirpstack/configuration/region_au915_4.toml | 6 ++++ chirpstack/configuration/region_au915_5.toml | 6 ++++ chirpstack/configuration/region_au915_6.toml | 6 ++++ chirpstack/configuration/region_au915_7.toml | 6 ++++ chirpstack/configuration/region_cn470_0.toml | 6 ++++ chirpstack/configuration/region_cn470_1.toml | 6 ++++ chirpstack/configuration/region_cn470_10.toml | 6 ++++ chirpstack/configuration/region_cn470_11.toml | 6 ++++ chirpstack/configuration/region_cn470_2.toml | 6 ++++ chirpstack/configuration/region_cn470_3.toml | 6 ++++ chirpstack/configuration/region_cn470_4.toml | 6 ++++ chirpstack/configuration/region_cn470_5.toml | 6 ++++ chirpstack/configuration/region_cn470_6.toml | 6 ++++ chirpstack/configuration/region_cn470_7.toml | 6 ++++ chirpstack/configuration/region_cn470_8.toml | 6 ++++ chirpstack/configuration/region_cn470_9.toml | 6 ++++ chirpstack/configuration/region_cn779.toml | 6 ++++ chirpstack/configuration/region_eu433.toml | 6 ++++ chirpstack/configuration/region_eu868.toml | 6 ++++ chirpstack/configuration/region_in865.toml | 6 ++++ chirpstack/configuration/region_ism2400.toml | 6 ++++ chirpstack/configuration/region_kr920.toml | 6 ++++ chirpstack/configuration/region_ru864.toml | 6 ++++ chirpstack/configuration/region_us915_0.toml | 6 ++++ chirpstack/configuration/region_us915_1.toml | 6 ++++ chirpstack/configuration/region_us915_2.toml | 6 ++++ chirpstack/configuration/region_us915_3.toml | 6 ++++ chirpstack/configuration/region_us915_4.toml | 6 ++++ chirpstack/configuration/region_us915_5.toml | 6 ++++ chirpstack/configuration/region_us915_6.toml | 6 ++++ chirpstack/configuration/region_us915_7.toml | 6 ++++ chirpstack/src/cmd/configfile.rs | 6 ++++ chirpstack/src/config.rs | 28 +++++++++++++++++-- chirpstack/src/gateway/backend/mqtt.rs | 1 + chirpstack/src/integration/mqtt.rs | 1 + 43 files changed, 267 insertions(+), 3 deletions(-) diff --git a/chirpstack/configuration/region_as923.toml b/chirpstack/configuration/region_as923.toml index a8267645..0d2b1680 100644 --- a/chirpstack/configuration/region_as923.toml +++ b/chirpstack/configuration/region_as923.toml @@ -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://...) diff --git a/chirpstack/configuration/region_as923_2.toml b/chirpstack/configuration/region_as923_2.toml index 75f08257..e14dabcd 100644 --- a/chirpstack/configuration/region_as923_2.toml +++ b/chirpstack/configuration/region_as923_2.toml @@ -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://...) diff --git a/chirpstack/configuration/region_as923_3.toml b/chirpstack/configuration/region_as923_3.toml index 8665e9cf..e24d8f62 100644 --- a/chirpstack/configuration/region_as923_3.toml +++ b/chirpstack/configuration/region_as923_3.toml @@ -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://...) diff --git a/chirpstack/configuration/region_as923_4.toml b/chirpstack/configuration/region_as923_4.toml index 703d1676..f0901ed6 100644 --- a/chirpstack/configuration/region_as923_4.toml +++ b/chirpstack/configuration/region_as923_4.toml @@ -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://...) diff --git a/chirpstack/configuration/region_au915_0.toml b/chirpstack/configuration/region_au915_0.toml index 4323e7c0..6f3b8e8b 100644 --- a/chirpstack/configuration/region_au915_0.toml +++ b/chirpstack/configuration/region_au915_0.toml @@ -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://...) diff --git a/chirpstack/configuration/region_au915_1.toml b/chirpstack/configuration/region_au915_1.toml index 7323a2a6..d6e568ed 100644 --- a/chirpstack/configuration/region_au915_1.toml +++ b/chirpstack/configuration/region_au915_1.toml @@ -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://...) diff --git a/chirpstack/configuration/region_au915_2.toml b/chirpstack/configuration/region_au915_2.toml index 161a753a..729e52a1 100644 --- a/chirpstack/configuration/region_au915_2.toml +++ b/chirpstack/configuration/region_au915_2.toml @@ -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://...) diff --git a/chirpstack/configuration/region_au915_3.toml b/chirpstack/configuration/region_au915_3.toml index 74a13a57..339bae1d 100644 --- a/chirpstack/configuration/region_au915_3.toml +++ b/chirpstack/configuration/region_au915_3.toml @@ -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://...) diff --git a/chirpstack/configuration/region_au915_4.toml b/chirpstack/configuration/region_au915_4.toml index 57c15ec8..22c3dfc6 100644 --- a/chirpstack/configuration/region_au915_4.toml +++ b/chirpstack/configuration/region_au915_4.toml @@ -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://...) diff --git a/chirpstack/configuration/region_au915_5.toml b/chirpstack/configuration/region_au915_5.toml index 2d2ce029..815a1694 100644 --- a/chirpstack/configuration/region_au915_5.toml +++ b/chirpstack/configuration/region_au915_5.toml @@ -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://...) diff --git a/chirpstack/configuration/region_au915_6.toml b/chirpstack/configuration/region_au915_6.toml index 476befa1..4d594038 100644 --- a/chirpstack/configuration/region_au915_6.toml +++ b/chirpstack/configuration/region_au915_6.toml @@ -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://...) diff --git a/chirpstack/configuration/region_au915_7.toml b/chirpstack/configuration/region_au915_7.toml index e51ffcc0..c235d2fc 100644 --- a/chirpstack/configuration/region_au915_7.toml +++ b/chirpstack/configuration/region_au915_7.toml @@ -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://...) diff --git a/chirpstack/configuration/region_cn470_0.toml b/chirpstack/configuration/region_cn470_0.toml index 8de8c7c0..0ebcde4e 100644 --- a/chirpstack/configuration/region_cn470_0.toml +++ b/chirpstack/configuration/region_cn470_0.toml @@ -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://...) diff --git a/chirpstack/configuration/region_cn470_1.toml b/chirpstack/configuration/region_cn470_1.toml index 59496972..cd6c1a3b 100644 --- a/chirpstack/configuration/region_cn470_1.toml +++ b/chirpstack/configuration/region_cn470_1.toml @@ -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://...) diff --git a/chirpstack/configuration/region_cn470_10.toml b/chirpstack/configuration/region_cn470_10.toml index abcd3ce2..3ed0e039 100644 --- a/chirpstack/configuration/region_cn470_10.toml +++ b/chirpstack/configuration/region_cn470_10.toml @@ -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://...) diff --git a/chirpstack/configuration/region_cn470_11.toml b/chirpstack/configuration/region_cn470_11.toml index 0fd37c8a..bb491db1 100644 --- a/chirpstack/configuration/region_cn470_11.toml +++ b/chirpstack/configuration/region_cn470_11.toml @@ -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://...) diff --git a/chirpstack/configuration/region_cn470_2.toml b/chirpstack/configuration/region_cn470_2.toml index 0bc42933..995f5db3 100644 --- a/chirpstack/configuration/region_cn470_2.toml +++ b/chirpstack/configuration/region_cn470_2.toml @@ -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://...) diff --git a/chirpstack/configuration/region_cn470_3.toml b/chirpstack/configuration/region_cn470_3.toml index f75cf968..20d88aa5 100644 --- a/chirpstack/configuration/region_cn470_3.toml +++ b/chirpstack/configuration/region_cn470_3.toml @@ -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://...) diff --git a/chirpstack/configuration/region_cn470_4.toml b/chirpstack/configuration/region_cn470_4.toml index 95b52cc7..2dff0da0 100644 --- a/chirpstack/configuration/region_cn470_4.toml +++ b/chirpstack/configuration/region_cn470_4.toml @@ -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://...) diff --git a/chirpstack/configuration/region_cn470_5.toml b/chirpstack/configuration/region_cn470_5.toml index 578eb058..c8d11088 100644 --- a/chirpstack/configuration/region_cn470_5.toml +++ b/chirpstack/configuration/region_cn470_5.toml @@ -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://...) diff --git a/chirpstack/configuration/region_cn470_6.toml b/chirpstack/configuration/region_cn470_6.toml index d118dcb4..f3fdb8df 100644 --- a/chirpstack/configuration/region_cn470_6.toml +++ b/chirpstack/configuration/region_cn470_6.toml @@ -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://...) diff --git a/chirpstack/configuration/region_cn470_7.toml b/chirpstack/configuration/region_cn470_7.toml index 719b93af..c252746a 100644 --- a/chirpstack/configuration/region_cn470_7.toml +++ b/chirpstack/configuration/region_cn470_7.toml @@ -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://...) diff --git a/chirpstack/configuration/region_cn470_8.toml b/chirpstack/configuration/region_cn470_8.toml index 8d4e5fa4..fae148a6 100644 --- a/chirpstack/configuration/region_cn470_8.toml +++ b/chirpstack/configuration/region_cn470_8.toml @@ -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://...) diff --git a/chirpstack/configuration/region_cn470_9.toml b/chirpstack/configuration/region_cn470_9.toml index 4cb46fd6..65c64c1f 100644 --- a/chirpstack/configuration/region_cn470_9.toml +++ b/chirpstack/configuration/region_cn470_9.toml @@ -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://...) diff --git a/chirpstack/configuration/region_cn779.toml b/chirpstack/configuration/region_cn779.toml index ced99342..d945c033 100644 --- a/chirpstack/configuration/region_cn779.toml +++ b/chirpstack/configuration/region_cn779.toml @@ -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://...) diff --git a/chirpstack/configuration/region_eu433.toml b/chirpstack/configuration/region_eu433.toml index c15367cb..676cd5d6 100644 --- a/chirpstack/configuration/region_eu433.toml +++ b/chirpstack/configuration/region_eu433.toml @@ -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://...) diff --git a/chirpstack/configuration/region_eu868.toml b/chirpstack/configuration/region_eu868.toml index 8812ebb3..9df2ae2b 100644 --- a/chirpstack/configuration/region_eu868.toml +++ b/chirpstack/configuration/region_eu868.toml @@ -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://...) diff --git a/chirpstack/configuration/region_in865.toml b/chirpstack/configuration/region_in865.toml index 609b55d3..affc31ec 100644 --- a/chirpstack/configuration/region_in865.toml +++ b/chirpstack/configuration/region_in865.toml @@ -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://...) diff --git a/chirpstack/configuration/region_ism2400.toml b/chirpstack/configuration/region_ism2400.toml index 50d2ce23..3764e4f0 100644 --- a/chirpstack/configuration/region_ism2400.toml +++ b/chirpstack/configuration/region_ism2400.toml @@ -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://...) diff --git a/chirpstack/configuration/region_kr920.toml b/chirpstack/configuration/region_kr920.toml index ebdfff09..b7da9f5f 100644 --- a/chirpstack/configuration/region_kr920.toml +++ b/chirpstack/configuration/region_kr920.toml @@ -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://...) diff --git a/chirpstack/configuration/region_ru864.toml b/chirpstack/configuration/region_ru864.toml index d7578bdd..f0bae197 100644 --- a/chirpstack/configuration/region_ru864.toml +++ b/chirpstack/configuration/region_ru864.toml @@ -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://...) diff --git a/chirpstack/configuration/region_us915_0.toml b/chirpstack/configuration/region_us915_0.toml index 9953c49d..b269814a 100644 --- a/chirpstack/configuration/region_us915_0.toml +++ b/chirpstack/configuration/region_us915_0.toml @@ -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://...) diff --git a/chirpstack/configuration/region_us915_1.toml b/chirpstack/configuration/region_us915_1.toml index 30611769..6ff67494 100644 --- a/chirpstack/configuration/region_us915_1.toml +++ b/chirpstack/configuration/region_us915_1.toml @@ -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://...) diff --git a/chirpstack/configuration/region_us915_2.toml b/chirpstack/configuration/region_us915_2.toml index 94620139..217b935a 100644 --- a/chirpstack/configuration/region_us915_2.toml +++ b/chirpstack/configuration/region_us915_2.toml @@ -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://...) diff --git a/chirpstack/configuration/region_us915_3.toml b/chirpstack/configuration/region_us915_3.toml index e507cf0c..e5ebb409 100644 --- a/chirpstack/configuration/region_us915_3.toml +++ b/chirpstack/configuration/region_us915_3.toml @@ -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://...) diff --git a/chirpstack/configuration/region_us915_4.toml b/chirpstack/configuration/region_us915_4.toml index f9e23be2..3f6eac44 100644 --- a/chirpstack/configuration/region_us915_4.toml +++ b/chirpstack/configuration/region_us915_4.toml @@ -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://...) diff --git a/chirpstack/configuration/region_us915_5.toml b/chirpstack/configuration/region_us915_5.toml index 11948c7d..8d22fe05 100644 --- a/chirpstack/configuration/region_us915_5.toml +++ b/chirpstack/configuration/region_us915_5.toml @@ -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://...) diff --git a/chirpstack/configuration/region_us915_6.toml b/chirpstack/configuration/region_us915_6.toml index aee3b346..699c2701 100644 --- a/chirpstack/configuration/region_us915_6.toml +++ b/chirpstack/configuration/region_us915_6.toml @@ -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://...) diff --git a/chirpstack/configuration/region_us915_7.toml b/chirpstack/configuration/region_us915_7.toml index 86818aa9..398b82df 100644 --- a/chirpstack/configuration/region_us915_7.toml +++ b/chirpstack/configuration/region_us915_7.toml @@ -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://...) diff --git a/chirpstack/src/cmd/configfile.rs b/chirpstack/src/cmd/configfile.rs index cfc08a43..9fde489c 100644 --- a/chirpstack/src/cmd/configfile.rs +++ b/chirpstack/src/cmd/configfile.rs @@ -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://...) diff --git a/chirpstack/src/config.rs b/chirpstack/src/config.rs index ea4e1c6c..e15c3e4f 100644 --- a/chirpstack/src/config.rs +++ b/chirpstack/src/config.rs @@ -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)] diff --git a/chirpstack/src/gateway/backend/mqtt.rs b/chirpstack/src/gateway/backend/mqtt.rs index a51041db..db4a87de 100644 --- a/chirpstack/src/gateway/backend/mqtt.rs +++ b/chirpstack/src/gateway/backend/mqtt.rs @@ -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() { diff --git a/chirpstack/src/integration/mqtt.rs b/chirpstack/src/integration/mqtt.rs index 13936747..fa6c0592 100644 --- a/chirpstack/src/integration/mqtt.rs +++ b/chirpstack/src/integration/mqtt.rs @@ -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() {