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. Qt Mqtt not connecting
Forum Updated to NodeBB v4.3 + New Features

Qt Mqtt not connecting

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 863 Views 2 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.
  • L Offline
    L Offline
    lodeSmets
    wrote on last edited by
    #1

    Hello,

    I have read the documentation and the example code for the Qt Mqtt library.
    Now I'm trying to create my own client, but the QMqttClient won't connect to the broker

        QMqttClient *client= new QMqttClient();
        client->setHostname("192.168.0.137");
        client->setPort(1883);
        client->connectToHost();
    
        QMqttClient::ClientState state =client->state();
        while (client->state()==QMqttClient::Connecting);
    

    When debugging the state is always connecting (never connected).
    I know the library works (because the example code works).
    Is there something I forgot?

    Thanks in advance,
    Lode

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

      Hi,

      You might be strangling the event loop with that while loop.

      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
      2
      • Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @lodeSmets said in Qt Mqtt not connecting:

        I have read the documentation and the example code for the Qt Mqtt library.

        So you have seen that the simpleclient for instance doesn't have any loop, and it's "event-based" using just signals and slots.

        And out of curiosity and for statistical purposes, what server (i.e. Mosquitto) are you trying to connect to? Thanks.

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        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