Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QtMqtt subscription problem
Qt 6.11 is out! See what's new in the release blog

QtMqtt subscription problem

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 2 Posters 932 Views 1 Watching
  • 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.
  • P Offline
    P Offline
    PhysicsX
    wrote on last edited by
    #1

    Hello

    I interested in qtmqtt library.
    I simply compiled and make it ready to use for raspberry pi.

    When try to write simple subscription appliocation it will fail. Like:

            QMqttClient *m_client;
            m_client = new QMqttClient();
            m_client->setHostname(QString("iot.reyax.com"));
            m_client->setPort(1883);
            m_client->setUsername(QString("zFtbPwRwxE"));
            m_client->setPassword(QString("GhMshMhWG9"));
    
            auto subscription = m_client->subscribe(QString("api/command/28/#"), 0);
               if (!subscription) {
                   qDebug()<<"Can not subscribe to topic";
    
    

    But when I put two buttons (first one is responsible to set hostname, port vs and the second one is respobsible for subscription) then everthing will work interestingly.

    I put some delay, sleep before m_client->subscribe but it do not work.

    I use for the cloud -> http://reyax.com/wp-content/uploads/2017/10/RYC1001_Application_note_Windows_MQTT.FX_.pdf you can try the password and other related stuff for connection from this pdf.

    Simply I need to make subscription available in the simple namespace. Why it is not working when I try to run like this ( above code snippet )
    my qt version 5.14.2

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You should do some error checking with QMqttClient::error.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • P Offline
        P Offline
        PhysicsX
        wrote on last edited by
        #3

        Hi SGaist

        Thanks for the answer.

        Could you provide any example ?
        I only set some strings. Why should I check some errors after this ?

        Thank you.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Because you are then subscribing which will trigger network connection which might fail for some reasons that might be explained through that property.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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