Skip to content
Snippets Groups Projects
  • Rob Swindell's avatar
    b4aaddb8
    Remove MQTT message publishing from mqtt_connect_callback() · b4aaddb8
    Rob Swindell authored
    A follow-up to commit 81d4575e
    
    Although I was not able to successfully reproduce the problem that Ree
    reported with his commit (even when changing the SCFG->Networks->MQTT->Publish
    QOS to 1: At least once) on Windows, I do see how this problem could
    theoretically happen. And like Ree said in the follow-up comment on the MR
    "maybe these two lines should have stayed in mqtt_startup", they don't really
    belong in the connection callback.
    
    The "client" topics only needs to be cleared upon startup or recycle (by
    publishing a null message) and it would be bad to clear these topics whenever
    the broker was reconnected (the server's clients didn't magically disconnect).
    So these "client" topic-clearing publishes are now only done during startup
    (again).
    
    The "recycle" topics don't really need to be published to here at all. I
    think I only did this for cases where someone published a non-null message to
    the topic and its stale message would remain afterward, appearing in MQTT
    browsers (like MQTT explorer) long after the server had recycled. The real
    solution to this cosmetic issue is to only publish null (0-length) messages to
    the "recycle" topics in the first place.
    b4aaddb8
    History
    Remove MQTT message publishing from mqtt_connect_callback()
    Rob Swindell authored
    A follow-up to commit 81d4575e
    
    Although I was not able to successfully reproduce the problem that Ree
    reported with his commit (even when changing the SCFG->Networks->MQTT->Publish
    QOS to 1: At least once) on Windows, I do see how this problem could
    theoretically happen. And like Ree said in the follow-up comment on the MR
    "maybe these two lines should have stayed in mqtt_startup", they don't really
    belong in the connection callback.
    
    The "client" topics only needs to be cleared upon startup or recycle (by
    publishing a null message) and it would be bad to clear these topics whenever
    the broker was reconnected (the server's clients didn't magically disconnect).
    So these "client" topic-clearing publishes are now only done during startup
    (again).
    
    The "recycle" topics don't really need to be published to here at all. I
    think I only did this for cases where someone published a non-null message to
    the topic and its stale message would remain afterward, appearing in MQTT
    browsers (like MQTT explorer) long after the server had recycled. The real
    solution to this cosmetic issue is to only publish null (0-length) messages to
    the "recycle" topics in the first place.