1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

mqtt: Do not attempt validating topics if they are not set

Signed-off-by: Steffen Vogel <steffen.vogel@opal-rt.com>
This commit is contained in:
Steffen Vogel 2024-03-07 16:26:43 +00:00 committed by pipeacosta
parent 30a969c5bc
commit 250d016a98

View file

@ -246,15 +246,19 @@ int villas::node::mqtt_check(NodeCompat *n) {
int ret;
auto *m = n->getData<struct mqtt>();
ret = mosquitto_sub_topic_check(m->subscribe);
if (ret != MOSQ_ERR_SUCCESS)
throw RuntimeError("Invalid subscribe topic: '{}': {}", m->subscribe,
mosquitto_strerror(ret));
if (m->subscribe) {
ret = mosquitto_sub_topic_check(m->subscribe);
if (ret != MOSQ_ERR_SUCCESS)
throw RuntimeError("Invalid subscribe topic: '{}': {}", m->subscribe,
mosquitto_strerror(ret));
}
ret = mosquitto_pub_topic_check(m->publish);
if (ret != MOSQ_ERR_SUCCESS)
throw RuntimeError("Invalid publish topic: '{}': {}", m->publish,
mosquitto_strerror(ret));
if (m->publish) {
ret = mosquitto_pub_topic_check(m->publish);
if (ret != MOSQ_ERR_SUCCESS)
throw RuntimeError("Invalid publish topic: '{}': {}", m->publish,
mosquitto_strerror(ret));
}
return 0;
}