diff --git a/server/model/monitor.js b/server/model/monitor.js index 4df6d0e9e..8e1843cd6 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -939,6 +939,7 @@ class Monitor extends BeanModel { ssl: this.kafkaProducerSsl, clientId: `Uptime-Kuma/${version}`, interval: this.interval, + connectionTimeout: this.timeout, }, JSON.parse(this.kafkaProducerSaslOptions) ); diff --git a/server/util-server.js b/server/util-server.js index 23de51b12..a6bf06119 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -213,7 +213,13 @@ exports.pingAsync = function ( */ exports.kafkaProducerAsync = function (brokers, topic, message, options = {}, saslOptions = {}) { return new Promise((resolve, reject) => { - const { interval = 20, allowAutoTopicCreation = false, ssl = false, clientId = "Uptime-Kuma" } = options; + const { + interval = 20, + allowAutoTopicCreation = false, + ssl = false, + clientId = "Uptime-Kuma", + connectionTimeout = 1, + } = options; let connectedToKafka = false; @@ -238,6 +244,7 @@ exports.kafkaProducerAsync = function (brokers, topic, message, options = {}, sa retries: 0, }, ssl: ssl, + connectionTimeout: connectionTimeout * 1000, }); let producer = client.producer({ diff --git a/src/lang/en.json b/src/lang/en.json index a7dbc97c7..c6c1259c6 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -87,6 +87,7 @@ "Path": "Path", "Heartbeat Interval": "Heartbeat Interval", "Request Timeout": "Request Timeout", + "Connection Timeout": "Connection Timeout", "timeoutAfter": "Timeout after {0} seconds", "Retries": "Retries", "Heartbeat Retry Interval": "Heartbeat Retry Interval", diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 2ee2e66ae..b93d0a928 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -1499,12 +1499,19 @@ monitor.type === 'ping' || monitor.type === 'rabbitmq' || monitor.type === 'snmp' || - monitor.type === 'websocket-upgrade' + monitor.type === 'websocket-upgrade' || + monitor.type === 'kafka-producer' " class="my-3" >