-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bridge notifications behavior for WITH_ADNS=y and WITH_ADNS=n option #1902
Comments
related #1488 |
Ok, I spent more time on this and problem is more complicated. It seems that The easiest quick fix for that would be to use LWT, but not send it if diff --git a/lib/send_connect.c b/lib/send_connect.c
index 2ad8fdf..c2137bd 100644
--- a/lib/send_connect.c
+++ b/lib/send_connect.c
@@ -100,7 +100,11 @@ int send__connect(struct mosquitto *mosq, uint16_t keepalive, bool clean_session
}else{
payloadlen = 2;
}
+#ifdef WITH_BROKER
+ if(mosq->will && (!mosq->bridge || !mosq->bridge->notifications_local_only)){
+#else
if(mosq->will){
+#endif
will = 1;
assert(mosq->will->msg.topic);
diff --git a/src/bridge.c b/src/bridge.c
index c951c8c..e3cd9dd 100644
--- a/src/bridge.c
+++ b/src/bridge.c
@@ -355,12 +355,10 @@ int bridge__connect(struct mosquitto_db *db, struct mosquitto *context)
context->bridge->initial_notification_done = true;
}
- if (!context->bridge->notifications_local_only) {
- notification_payload = '0';
- rc = will__set(context, context->bridge->notification_topic, 1, ¬ification_payload, 1, true, NULL);
- if(rc != MOSQ_ERR_SUCCESS){
- return rc;
- }
+ notification_payload = '0';
+ rc = will__set(context, context->bridge->notification_topic, 1, ¬ification_payload, 1, true, NULL);
+ if(rc != MOSQ_ERR_SUCCESS){
+ return rc;
}
}else{
notification_topic_len = strlen(context->bridge->remote_clientid)+strlen("$SYS/broker/connection//state");
@@ -375,13 +373,11 @@ int bridge__connect(struct mosquitto_db *db, struct mosquitto *context)
context->bridge->initial_notification_done = true;
}
- if (!context->bridge->notifications_local_only) {
- notification_payload = '0';
- rc = will__set(context, notification_topic, 1, ¬ification_payload, 1, true, NULL);
- mosquitto__free(notification_topic);
- if(rc != MOSQ_ERR_SUCCESS){
- return rc;
- }
+ notification_payload = '0';
+ rc = will__set(context, notification_topic, 1, ¬ification_payload, 1, true, NULL);
+ mosquitto__free(notification_topic);
+ if(rc != MOSQ_ERR_SUCCESS){
+ return rc;
}
}
} |
With this fix, you can bridge to AWS (which does not support LWT) and have local bridge status ( |
@marcinkowskip we have been struggling with the same issue connecting Mosquitto bridge to AWS IoT with configuration ( |
Not sure if I follow you. The issue is not related to retained messages at all. The issue is strictly related to sharing LWT message to notify bridge status for both remote and local setup. If you set |
This is for when `notifications_local_only` was set true. Closes #1902. Thanks to marcinkowskip.
This looks good to me, thanks very much! |
This is for when `notifications_local_only` was set true. Closes eclipse#1902. Thanks to marcinkowskip.
Hello,
According to the topic. Is there any reason why notifications don't work the same way based on the option? I am talking about lines:
https://github.com/eclipse/mosquitto/blob/master/src/bridge.c#L180
https://github.com/eclipse/mosquitto/blob/master/src/bridge.c#L358
The second function has
if
statement.I run into this problem when I wanted to enable local notifications for AWS bridge, but I could not because lack of the condition. I locally changed line 180 to match 358 (copied
if
statement) and everything worked correctly.Thanks,
PM
The text was updated successfully, but these errors were encountered: