QtMqtt subscription problem
-
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 -
Hi,
You should do some error checking with QMqttClient::error.
-
Because you are then subscribing which will trigger network connection which might fail for some reasons that might be explained through that property.