Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Mqtt subscription - No notify with topic subscription, using '+' and '#' together
QtWS25 Last Chance

Mqtt subscription - No notify with topic subscription, using '+' and '#' together

Scheduled Pinned Locked Moved Unsolved General and Desktop
mqttwildcards
2 Posts 2 Posters 299 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nicolobracchi40
    wrote on last edited by
    #1

    We noticed that when we try to send a topic via MQTT in our QT (6.5.2) quick application, we get an error using Multi-level wildcard ('#'), and Single-level wildcard ('+'), both in the same topic.

    Example:
          if our app subscribes this topic:

    "persint/1/+/msa/#"

    and via MQTT Explorer we publish:

    "persint/1/2/msa/3"

    the app is not notified.

    How to fix it?

    This is the link of MQTT doc:

    https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.pdf

    and this is an app example with relative output:

    QMqttTopicFilter globalFilter{"foo/+/#"};
        QMqttTopicName topicName("foo/pippo/bar");
        if(globalFilter.isValid()) {
            qDebug() << "FILTER VALID";
            if (globalFilter.match(topicName)) {
                qDebug() << "TOPIC MATCH";
            }
            else {
                qDebug() << "TOPIC NO MATCH";
            }
        }
        else {
            qDebug() << "FILTER NOT VALID";
        }
    

    and the output is:

    FILTER VALID
    TOPIC NO MATCH
    
    JKSHJ 1 Reply Last reply
    3
    • N nicolobracchi40

      We noticed that when we try to send a topic via MQTT in our QT (6.5.2) quick application, we get an error using Multi-level wildcard ('#'), and Single-level wildcard ('+'), both in the same topic.

      Example:
            if our app subscribes this topic:

      "persint/1/+/msa/#"

      and via MQTT Explorer we publish:

      "persint/1/2/msa/3"

      the app is not notified.

      How to fix it?

      This is the link of MQTT doc:

      https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.pdf

      and this is an app example with relative output:

      QMqttTopicFilter globalFilter{"foo/+/#"};
          QMqttTopicName topicName("foo/pippo/bar");
          if(globalFilter.isValid()) {
              qDebug() << "FILTER VALID";
              if (globalFilter.match(topicName)) {
                  qDebug() << "TOPIC MATCH";
              }
              else {
                  qDebug() << "TOPIC NO MATCH";
              }
          }
          else {
              qDebug() << "FILTER NOT VALID";
          }
      

      and the output is:

      FILTER VALID
      TOPIC NO MATCH
      
      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi @nicolobracchi40, and welcome!

      This looks like a bug. See https://bugreports.qt.io/browse/QTBUG-104478

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved