Giter VIP home page Giter VIP logo

qmqtt's Introduction

QMQTT

mqtt client for Qt 5 in maintenance status

Please compile the library with Qt >= 5.3 version. On Windows you need to specify CONFIG += NO_UNIT_TESTS, since gtest is not supported.

SSL is enabled by default, if the version of OpenSSL < 1.0.2, SSL may not be supported.

Disable the SSL in CMakeLists.txt (cmake):

option( ${PROJECT_NAME}_SSL "Enable SSL support for MQTT" OFF )

Disable the SSL with src/mqtt/qmqtt.pro (qmake):

CONFIG += QMQTT_NO_SSL

To add websocket support, compile the library with Qt >= 5.7, and specify 'CONFIG += QMQTT_WEBSOCKETS'. This also works when compiling qmqtt for WebAssembly.

Usage

In your QMake project, add:

QT += qmqtt

Connect using TCP:

#include "qmqtt.h"

QMQTT::Client *client = new QMQTT::Client(QHostAddress::LocalHost, 1883);
client->setClientId("clientId");
client->setUsername("user");
client->setPassword("password");
client->connectToHost();

Connect using SSL:

QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration();
// Add custom SSL options here (for example extra certificates)
QMQTT::Client *client = new QMQTT::Client("example.com", 8883, sslConfig);
client->setClientId("clientId");
client->setUsername("user");
client->setPassword("password");
// Optionally, set ssl errors you want to ignore. Be careful, because this may weaken security.
// See QSslSocket::ignoreSslErrors(const QList<QSslError> &) for more information.
client->ignoreSslErrors(<list of expected ssl errors>)
client->connectToHost();
// Here's another option to suppress SSL errors (again, be careful)
QObject::connect(client, &QMQTT::Client::sslErrors, [&](const QList<QSslError> &errors) {
    // Investigate the errors here, if you find no serious problems, call ignoreSslErrors()
    // to continue connecting.
    client->ignoreSslErrors();
});

Connect using WebSockets:

QMQTT::Client *client = new QMQTT::Client("ws://www.example.com/mqtt", "<origin>", QWebSocketProtocol::VersionLatest);
client->setClientId("clientId");
client->setUsername("user");
client->setPassword("password");
client->connectToHost();

Slots

void setHost(const QHostAddress& host);
void setPort(const quint16 port);
void setClientId(const QString& clientId);
void setUsername(const QString& username);
void setPassword(const QString& password);
void setKeepAlive(const int keepAlive);
void setCleanSession(const bool cleansess);
void setAutoReconnect(const bool value);
void setAutoReconnectInterval(const int autoReconnectInterval);
void setWillTopic(const QString& willTopic);
void setWillQos(const quint8 willQos);
void setWillRetain(const bool willRetain);
void setWillMessage(const QString& willMessage);

void connectToHost();
void disconnectFromHost();

quint16 subscribe(const QString& topic, const quint8 qos);
void unsubscribe(const QString& topic);

quint16 publish(const Message& message);

Signals

void connected();
void disconnected();
void error(const QMQTT::ClientError error);

void subscribed(const QString& topic, const quint8 qos);
void unsubscribed(const QString& topic);
void published(const quint16 msgid, const quint8 qos);
void pingresp();
void received(const QMQTT::Message& message);

Qt 6 support

This library has been developed and tested against Qt 5. Active work on it has stopped since Qt released its own mqtt module several years ago. There are currently no plans for further extensions except for smaller rectifications and bug fixing. At your own risk you may use it in Qt6 projects using cmake.

License

New BSD License

Contributors

@avsdev-cw, @alex-spataru, Benjamin Schmitz, @bf-bryants, @bog-dan-ro, @chsterz, @cncap, @ejvr, @ehntoo, Erik Botö, Guillaume Bour, @halfgaar, @hxcan, @jpnurmi, Kai Dohmen, @Kampfgnom, @keytee, @kollix, @KonstantinRitt, @maggu2810, @mwallnoefer, @NicoWallmeier, Niklas Wulf, Niraj Desai, @Psy-Kai, @rafaeldelucena, @rokm, @RoachLin, @sergey-kuzminov, sgaoemq, @Vortex375, ybq

Authors

@emqplus Feng Lee [email protected]

@wguynes William Guynes [email protected]

@wuming123057 Xuan [email protected]

qmqtt's People

Contributors

alex-spataru avatar avsdev-cw avatar bf-bryants avatar bog-dan-ro avatar carlonluca avatar chsterz avatar cncap avatar ehntoo avatar ejvr avatar emqplus avatar halfgaar avatar hxcan avatar jpnurmi avatar kampfgnom avatar keytee avatar kollix avatar konstantinritt avatar maggu2810 avatar mincequi avatar mwallnoefer avatar nicowallmeier avatar rafaeldelucena avatar rokm avatar sbradford26 avatar sergey-kuzminov avatar v1l3g0d avatar wanghaemq avatar wguynes avatar wuming123057 avatar xinyi-xs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qmqtt's Issues

Porting qmqtt to Android

Hi guys!
has anyone tried to port this mqtt client to android? I can run it in Desktop without problems but I have some issue with: library "libqmqtt.so" not found. Since I'm new in QT and Android I don't really have idea what the problem is. Could someone help me?

Thanks,
Fernando

Major, hopefully final public interface break

My [upcoming] changeset is going to make the public interface more solid.

  • Full PIMPL pattern for the public API for ABI compatibility.
  • Renaming a few functions, QMQTT::Client::connect() is a dangerous override and is going to cause user (developer) confusion. I am proposing change it to QMQTT::Client::connectToHost() which follows a Qt standard set by QTcpSocket
  • Isolation of header files. The user should only need qmqtt_client.h to compile and link with this library.

Once these changes are in, we will stop breaking source and binary compatibility as we enhance the library.

I do have some problems that need solutions:

  • Does anyone know the standard for eliminating the qmqtt_client.h dependence on qmqtt_global.h ? I know the global.h pattern is standard but what do we do once it is time to package it?
  • Are we really attached to the QMQTT::Will class? If the user must pass in an instance of this class then I have to expose the header file to them. I don't like that.

Qmqtt Android Build in Linux

Hi guys,

i try to compile the sources for android armv7 with qt5.8 in linux and it did not work. The Toolchain itself is working.
When i try to build the src.pro to get an library i get this error: /home/df/dev/qt/5.8/android_armv7/mkspecs/features/qt_module_headers.prf:153: error: Cannot write file /include/qmqtt/qmqtt
Depends: Cannot create parent directory
i tried a lot of different pro and qbs files of the project, but is not working.

when i try to build the src.qbs i get this error: /home/df/.config/QtProject/qtcreator/qbs/1.5.2/profiles/qtc_Android__feba1001/modules/Qt/core/core.qbs:136: error: TypeError: Result of expression 'qbs.toolchain' [undefined] is not an object.

for linux and windows it is working great btw!

thanks for your help!

Resending messages when QoS > 0 seems to be unimplemented

I couldn't find any code that would store messages and retransmit them if QoS > 0 and the server does not send a PUBACK - is this unimplemented or am I just not finding the relevant code?

It might be good to remove the QoS parameters if they're not actually supported so users don't get the wrong idea.

failed to connect to host or ssl certification error?need help !

I downloaded the last release code. Qt 5.7.1 + ubuntu 14.04 64bit.
I builded the .so files , and complied the example to connect the servers .
but failed .
some code:
` explicit Subscriber(const QString& hostName,
const quint16 port,
const QSslConfiguration& config,
const bool ignoreSelfSigned=false,
QObject* parent = NULL)
: QMQTT::Client(hostName, port, config, ignoreSelfSigned, parent)
{
}

const QString hostStr = QString ("ssl://backaudio-test.mqtt.iot.gz.baidubce.com");
const QString EXAMPLE_TOPIC_SUB = QString("one2one/server");
const quint16 EXAMPLE_PORT = 1884;

QString mqttClientId = "DeviceId-caiwei";
QString mqttUsername = "backaudio-test/server";
QByteArray mqttPassword = QByteArray("pnCRLWFbX5U1rw6grQHCLJ2DAxb2I9KByQbBLhqY/A4=");

QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration();

Subscriber subscriber(hostStr, EXAMPLE_PORT, sslConfig);
subscriber.setClientId(mqttClientId);
subscriber.setUsername(mqttUsername);
subscriber.setPassword(mqttPassword);
subscriber.connectToHost();`

i cant connect to the broker . error info:"qmqtt SSL: " "Host not found"
while i tried to connect to another host , error was reported : "qmqtt SSL: " "The issuer certificate of a locally looked up certificate could not be found"
the signal "void connected();" is not emitted.

I want to konw why i cant connect to broker. because i have wrong code , or wrong with sslconfiguration and certification ,or wrong with broker??

data is not parsed correctly

Hey,

qmqtt crashes for me regularly in the following method

quint16 Frame::readInt()
{
    char msb = _data.at(0);
    char lsb = _data.at(1);
    _data.remove(0, 2);
    return (msb << 8) + lsb;
}

the problem is that the _data is empty but there is no check for it so the assertion in .at() is triggered.
However, after a bit of debugging I think the problem happens before.

in void QMQTT::Network::onSocketReadReady() a Frame is created with the data
"8980,"x":-0.236530,"y":0.748594,"z":-0.022885,"ts"
Then this data is parsed in void QMQTT::ClientPrivate::onNetworkReceived(const QMQTT::Frame& frm) as a message (PUBLISH case) with the topic "80,"x":-0.236530,"y":0.748594,"z":-0.022885,"ts" as the 89 was interpreted as topic length and hence the frame data is empty. In the next step the crash occurs as the mid cannot be read from the empty data.

Obviously the data for the Frame in in void QMQTT::Network::onSocketReadReady() is incomplete. I actually send a JSON string like: "{ "acc": { "x":1, "y":1, "z":1,"ts":1} }" to a topic. Anyway, I did not investigate any further and I'm not aware how the mqtt data is send and received.

Any ideas how it comes to this behavior?

Using qmqtt under windows

Hi I have a hard time using the qmqtt under windows, work fine on MAC and linux, but on windows I get strange linker errors.

I can compile it into a lib, but then when using it I get linker errors.
If I just try to use it in a normale way, I also get errors.

A small number of the errors from the qml-qmqtt project
Makefile.Debug:125: recipe for target 'debug\mqtt.exe' failed
mingw32-make[1]: Leaving directory 'C:/Users/$hschack/Documents/qml-qmqtt'
makefile:34: recipe for target 'debug' failed
C:\Users$hschack\Documents\qml-qmqtt/debug/moc_qmqtt_client.cpp:211: undefined reference to _imp___ZN5QMQTT6Client12handlePubackEht' ./debug\moc_qmqtt_client.o: In functionZNK5QMQTT6Client10metaObjectEv':
C:\Users$hschack\Documents\qml-qmqtt/debug/moc_qmqtt_client.cpp:311: undefined reference to _imp___ZN5QMQTT6Client16staticMetaObjectE' ./debug\moc_qmqtt_client.o: In functionZN5QMQTT6Client11qt_metacallEN11QMetaObject4CallEiPPv':
C:\Users$hschack\Documents\qml-qmqtt/debug/moc_qmqtt_client.cpp:340: undefined reference to _imp___ZNK5QMQTT6Client4portEv' C:\Users\$hschack\Documents\qml-qmqtt/debug/moc_qmqtt_client.cpp:341: undefined reference to_imp___ZNK5QMQTT6Client4hostEv'
C:\Users$hschack\Documents\qml-qmqtt/debug/moc_qmqtt_client.cpp:342: undefined reference to _imp___ZNK5QMQTT6Client8clientIdEv' C:\Users\$hschack\Documents\qml-qmqtt/debug/moc_qmqtt_client.cpp:343: undefined reference to_imp___ZNK5QMQTT6Client8usernameEv'
C:\Users$hschack\Documents\qml-qmqtt/debug/moc_qmqtt_client.cpp:344: undefined reference to _imp___ZNK5QMQTT6Client8passwordEv' C:\Users\$hschack\Documents\qml-qmqtt/debug/moc_qmqtt_client.cpp:345: undefined reference to_imp___ZN5QMQTT6Client9keepaliveEv'
C:\Users$hschack\Documents\qml-qmqtt/debug/moc_qmqtt_client.cpp:346: undefined reference to _imp___ZNK5QMQTT6Client13autoReconnectEv' C:\Users\$hschack\Documents\qml-qmqtt/debug/moc_qmqtt_client.cpp:353: undefined reference to_imp___ZN5QMQTT6Client7setPortEj'
C:\Users$hschack\Documents\qml-qmqtt/debug/moc_qmqtt_client.cpp:354: undefined reference to _imp___ZN5QMQTT6Client7setHostERK7QString' C:\Users\$hschack\Documents\qml-qmqtt/debug/moc_qmqtt_client.cpp:355: undefined reference to_imp___ZN5QMQTT6Client11setClientIdERK7QString'
C:\Users$hschack\Documents\qml-qmqtt/debug/moc_qmqtt_client.cpp:356: undefined reference to _imp___ZN5QMQTT6Client11setUsernameERK7QString' C:\Users\$hschack\Documents\qml-qmqtt/debug/moc_qmqtt_client.cpp:357: undefined reference to_imp___ZN5QMQTT6Client11setPasswordERK7QString'
C:\Users$hschack\Documents\qml-qmqtt/debug/moc_qmqtt_client.cpp:358: undefined reference to _imp___ZN5QMQTT6Client12setKeepAliveEi' C:\Users\$hschack\Documents\qml-qmqtt/debug/moc_qmqtt_client.cpp:359: undefined reference to_imp___ZN5QMQTT6Client16setAutoReconnectEb'

connect to host failed

isConnectedToHost() always return false, why?
this is my code:
QMQTT::Client *client = new QMQTT::Client(QHostAddress::LocalHost, 1883);
client->setUsername("user");
client->setPassword("password");
client->setClientId("clientId");
if(client->isConnectedToHost()) {
...
connect sucessfule
}else {
...
connect to failed
}

thank you.

Building under Windows

Hello, sorry, I understand that my question is more in Qt sphere...
But I should to use qmqtt under windows and it's a pain for me.
Win7 x64, Qt5.7.1 with MinGW 5.3.
When I open qmqtt.pro I have next General messages:

Project WARNING: You should probably load(qt_build_config) first in mqtt.pro for qmqtt, as the latter also load()s qt_module.  
Project MESSAGE: Not doing so may lead to qt_module.prf overriding compiler/linker options in your .pro file.  
Project MESSAGE: Ignore this warning with CONFIG+=no_qt_module_warning if you know what you are doing.  
Project ERROR: Module does not define version. Error while parsing file C:\Users\user\Documents\qmqtt\src\mqtt\mqtt.pro. Giving up.  
[Inexact] Project MESSAGE: This project is using private headers and will therefore be tied to this specific Qt module build version.  
[Inexact] Project MESSAGE: Running this project against other versions of the Qt modules may crash at any arbitrary point.  
[Inexact] Project MESSAGE: This is not a bug, but a result of using Qt internals. You have been warned!  
Project MESSAGE: perl -w C:\Qt\Qt5.7.1\5.7\mingw53_32\bin\syncqt.pl -module qmqtt -version 1.0.0 -outdir C:/Users/user/Documents/build-qmqtt-Desktop_Qt_5_7_1_MinGW_32bit-Debug C:/Users/user/Documents/qmqtt  

I installed Perl anc CMake (thay are in PATH and works), because in first time it were a bit more messages)
But I can build it. I move manually includes and cmake file into Qt directories, but if I want to build example client application I have a message: error: Unknown module(s) in QT: mqtt
I understand that qmqtt folder looks like qt module, but I have a bit mess how to install it.
So, maybe you throw me a some ideas how to fix it.

Great thanks for your project!

Add "INSTALLS" to project-file

Hello,

could you please add an INSTALLS to the project file with an prefix?

isEmpty(PREFIX) {
    contains(MEEGO_EDITION,harmattan) {
        PREFIX = /usr
    } else:unix {
        PREFIX = /usr/local
    } else {
        PREFIX = $$[QT_INSTALL_PREFIX]
    }
}

headers.files = $$HEADERS
headers.path = $$PREFIX/include/qmqtt
target.path = $$PREFIX/lib
INSTALLS += headers target

This would simplify the installation alot.

(un)subscribed signal does not pass topic any more

The subscribe signal in QMQTT::Client still has a topic argument, but it will always be an empty string. Apparently the topic is not passed in the SUBACK message (See ClientPrivate::onNetworkReceived). The same goes for the unsubscribed signal.

Personally I do not have problems with this (not using the signals anyway), but I guess it may confuse people. Wouldn't it be better to remove the topic variable from the signals? The Client interface was already changed with pull request #96 which introduced the issue, so it seems OK to change it once more.

Problem compiling qmqtt in Windows

I am trying to compile the qmqtt subproject in Win7 using QtCreator 3.6.0 with MSVC SDK 7.1 (Qt 5.5.1).

The compilation stops in qmqtt_frame.cpp

64 Frame& Frame::Frame::operator=(const Frame& other)
65 {
66 _header = other._header;
67 _data = other._data;
68 return *this;
69 }

with the following errors:

C:\Qt\qmqtt-master\qmqtt-master\src\qmqtt_frame.cpp:64: error: C3083: '{ctor}': the symbol to the left of a '::' must be a type
C:\Qt\qmqtt-master\qmqtt-master\src\qmqtt_frame.cpp:65: error: C2556: 'QMQTT::Frame::Frame(const QMQTT::Frame &)' : overloaded function differs only by return type from 'QMQTT::Frame &QMQTT::Frame::operator =(const QMQTT::Frame &)'
c:\qt\qmqtt-master\qmqtt-master\src\qmqtt_frame.h:95: see declaration of 'QMQTT::Frame::operator ='

In the qmqtt_frame.h the deifnition is
Frame& operator=(const Frame& other);

Does anybody know what to do?

Qt Library Dependency

It would appear that due to QRegularExpressions and QLoggingCategory, this can only be compiled in >= Qt 5.2? I tried to comment out all of the QLoggingCategory calls, which works but then got nailed by the QRegularExpressions libraries vice QRegExp.

a) Is there a previous revision which operates under Qt 4.x ? (thinking for Raspberry Pi and the mainstream embedded stuff here)

b) could someone throw a note on the main readme to prevent others from similar pain

I have this client library compiled and running great in a Windows VM - I certainly appreciate the devs writing it!

Incoming MQTT message corruption

I have an application that is receiving many MQTT messages very quickly. And in one particular instance I found that it looked like the message data from multiple messages was being treated as the payload for a single message.

I was able to "fix" the issue by removing the QDataStream translation from the "void QMQTT::Network::onSocketReadReady()" function. I am not really sure why the QDataStream translation would cause such a problem, but this solved the problem for me.

My patch is attached.

qmqtt_network_corruption.patch.txt

Recommended way to run unit tests

I have some troubles running the tests with the updated/simplified build system. What is the recommended way to run all unit tests?

Things I already tried:

  • qmake && make: No tests built
  • qmake "QT_BUILD_PARTS += tests" && make: Testcases are built but qmqtt_tests fails because libmqtt.so can not be found (which should be found automatically now)

pkg-config reports wrong paths for qmqtt

I have installed the library by doing:

cd ..../qmqtt-master
mkdir build && cd build
sudo qmake ../src/mqtt/
sudo make install

and seems to work. This is the final part of the log, displaying installation paths:

   ...

ln -s libqmqtt.so.1.0.0 libqmqtt.so
ln -s libqmqtt.so.1.0.0 libqmqtt.so.1
ln -s libqmqtt.so.1.0.0 libqmqtt.so.1.0
rm -f /lib/libqmqtt.so.1.0.0
mv -f libqmqtt.so.1.0.0  /lib/ 
rm -f /lib/libqmqtt.so
rm -f /lib/libqmqtt.so.1
rm -f /lib/libqmqtt.so.1.0
mv -f libqmqtt.so /lib/ 
mv -f libqmqtt.so.1 /lib/ 
mv -f libqmqtt.so.1.0 /lib/ 
install -m 755 -p "/lib/libqmqtt.so.1.0.0" "/usr/lib/x86_64-linux-gnu/libqmqtt.so.1.0.0"
ln -f -s "libqmqtt.so.1.0.0" "/usr/lib/x86_64-linux-gnu/libqmqtt.so"
ln -f -s "libqmqtt.so.1.0.0" "/usr/lib/x86_64-linux-gnu/libqmqtt.so.1"
ln -f -s "libqmqtt.so.1.0.0" "/usr/lib/x86_64-linux-gnu/libqmqtt.so.1.0"
sed -e s,/include,/usr/include/x86_64-linux-gnu/qt5,g -e s,/lib,/usr/lib/x86_64-linux-gnu,g "/lib/libqmqtt.prl" >"/usr/lib/x86_64-linux-gnu/libqmqtt.prl"
sed -e s,/include,/usr/include/x86_64-linux-gnu/qt5,g -e s,/lib,/usr/lib/x86_64-linux-gnu,g "/lib/libqmqtt.la" >"/usr/lib/x86_64-linux-gnu/libqmqtt.la"
sed -e s,/include,/usr/include/x86_64-linux-gnu/qt5,g -e s,/lib,/usr/lib/x86_64-linux-gnu,g "/lib/pkgconfig/qmqtt.pc" >"/usr/lib/x86_64-linux-gnu/pkgconfig/qmqtt.pc"
install -m 644 -p /include/qmqtt/qmqttDepends /usr/include/x86_64-linux-gnu/qt5/qmqtt/
install -m 644 -p /mkspecs/modules-inst/qt_lib_mqtt.pri /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/
install -m 644 -p /mkspecs/modules-inst/qt_lib_mqtt_private.pri /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/
install -m 644 -p /lib/cmake/Qt5qmqtt/Qt5qmqttConfig.cmake /usr/lib/x86_64-linux-gnu/cmake/Qt5qmqtt/
install -m 644 -p /lib/cmake/Qt5qmqtt/Qt5qmqttConfigVersion.cmake /usr/lib/x86_64-linux-gnu/cmake/Qt5qmqtt/

But pkg-config reports wrong paths. For instance:

$ pkg-config qmqtt --cflags 
-I/usr/usr/include/x86_64-linux-gnu/qt5/x86_64-linux-gnu/qt5/qmqtt -I/usr/usr/include/x86_64-linux-gnu/qt5/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork

pkg-config points to '-I/usr/usr/include/x86_64-linux-gnu/qt5/x86_64-linux-gnu/qt5/qmqtt'
but the files were installed in '/usr/include/x86_64-linux-gnu/qt5/x86_64-linux-gnu/qt5/qmqtt'. Note an extra '/usr/' at beginning and duplicated 'x86_64-linux-gnu/qt5' folders.

This is the installed qmqtt.pc file:

prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/usr/lib/x86_64-linux-gnu/x86_64-linux-gnu
includedir=${prefix}/usr/include/x86_64-linux-gnu/qt5/x86_64-linux-gnu/qt5


Name: qmqtt
Description: qmqtt module
Version: 1.0.0
Libs: -L${libdir} -lqmqtt 
Libs.private: -lQt5Network -L/usr/usr/lib/x86_64-linux-gnu/x86_64-linux-gnu -lQt5Core -lpthread   
Cflags: -I${includedir}/qmqtt -I${includedir}
Requires: Qt5Core Qt5Network

As can be seen prefix=/usr creates a duplicate '/usr' folder in the paths. Also the paths have duplicated 'x86_64-linux-gnu/' and 'qt5'. A second issue is that folder '/usr/include/x86_64-linux-gnu/qt5/qmqtt' does not contain the headers for qmqtt bu just a file named 'qmqttDepends'. Are header files not copied during qmqtt library installation?.

All this need to be reviewed and fixed.

Help: Install and build instructions

I'm using Linux Mint 17.1 and Qt 5.9.1. I'm new to QT and I'm trying to use your qtmqtt library. But I'm having problems to install it. I downloaded the repo and tried to build out-of-source by doing:

mkdir build
cd build
qmake ..
make

But make fails. I also trried in-source building with the same results. In both cases the libqtmqtt is built, but make fails when compiling the examples:

   ...

g++ -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -Wl,-Bsymbolic-functions -Wl,-soname,libqmqtt.so.1 -o libqmqtt.so.1.0.0 .obj/qmqtt_client_p.o .obj/qmqtt_client.o .obj/qmqtt_frame.o .obj/qmqtt_message.o .obj/qmqtt_network.o .obj/qmqtt_routesubscription.o .obj/qmqtt_routedmessage.o .obj/qmqtt_router.o .obj/qmqtt_message_p.o .obj/qmqtt_socket.o .obj/qmqtt_ssl_socket.o .obj/qmqtt_timer.o .obj/moc_qmqtt_client.o .obj/moc_qmqtt_routesubscription.o .obj/moc_qmqtt_router.o .obj/moc_qmqtt_networkinterface.o .obj/moc_qmqtt_socketinterface.o .obj/moc_qmqtt_timerinterface.o .obj/moc_qmqtt_network_p.o .obj/moc_qmqtt_socket_p.o .obj/moc_qmqtt_ssl_socket_p.o .obj/moc_qmqtt_timer_p.o  -lQt5Network -L/usr/lib/x86_64-linux-gnu -lQt5Core -lpthread  
ln -s libqmqtt.so.1.0.0 libqmqtt.so
ln -s libqmqtt.so.1.0.0 libqmqtt.so.1
ln -s libqmqtt.so.1.0.0 libqmqtt.so.1.0
rm -f ../../lib/libqmqtt.so.1.0.0
mv -f libqmqtt.so.1.0.0  ../../lib/ 
rm -f ../../lib/libqmqtt.so
rm -f ../../lib/libqmqtt.so.1
rm -f ../../lib/libqmqtt.so.1.0
mv -f libqmqtt.so ../../lib/ 
mv -f libqmqtt.so.1 ../../lib/ 
mv -f libqmqtt.so.1.0 ../../lib/ 
make[2]: Leaving directory `/datos/USR/dev-qt/qmqtt/src/mqtt'
make[1]: Leaving directory `/datos/USR/dev-qt/qmqtt/src'
cd examples/ && ( test -e Makefile || /usr/lib/x86_64-linux-gnu/qt5/bin/qmake /datos/USR/dev-qt/qmqtt/examples/examples.pro -o Makefile ) && make -f Makefile 
make[1]: Entering directory `/datos/USR/dev-qt/qmqtt/examples'
cd mqtt/ && ( test -e Makefile || /usr/lib/x86_64-linux-gnu/qt5/bin/qmake /datos/USR/dev-qt/qmqtt/examples/mqtt/mqtt.pro -o Makefile ) && make -f Makefile 
make[2]: Entering directory `/datos/USR/dev-qt/qmqtt/examples/mqtt'
cd client/ && ( test -e Makefile || /usr/lib/x86_64-linux-gnu/qt5/bin/qmake /datos/USR/dev-qt/qmqtt/examples/mqtt/client/client.pro -o Makefile ) && make -f Makefile 
make[3]: Entering directory `/datos/USR/dev-qt/qmqtt/examples/mqtt/client'
/usr/lib/x86_64-linux-gnu/qt5/bin/moc -DQT_NO_MTDEV -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_MQTT_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I/datos/USR/dev-qt/qmqtt/examples/mqtt/client -I/datos/USR/dev-qt/qmqtt/include -I/datos/USR/dev-qt/qmqtt/include/qmqtt -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include example.cpp -o .moc/example.moc
g++ -c -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -O2 -fno-exceptions -Wall -W -D_REENTRANT -fPIE -DQT_NO_MTDEV -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_MQTT_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I. -I../../../include -I../../../include/qmqtt -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I.moc -o .obj/example.o example.cpp
example.cpp:32:19: fatal error: qmqtt.h: No such file or directory
 #include <qmqtt.h>
                   ^
compilation terminated.
make[3]: *** [.obj/example.o] Error 1
make[3]: Leaving directory `/datos/USR/dev-qt/qmqtt/examples/mqtt/client'
make[2]: *** [sub-client-make_first] Error 2
make[2]: Leaving directory `/datos/USR/dev-qt/qmqtt/examples/mqtt'
make[1]: *** [sub-mqtt-make_first] Error 2
make[1]: Leaving directory `/datos/USR/dev-qt/qmqtt/examples'
make: *** [sub-examples-make_first] Error 2

Probably, before attempting building the examples it is necessary to install the library and the headers but I don't know were QT expects to find them.

As the library qtmqtt seems to be created, I tried to build an example. For this I open client.pro with Qt Creator and tried to build. But fails with error: "Unknown module(s) in QT: mqtt".

I would appreciate instructions for properly installing the qtmqtt library and for testing the examples. Thank you.

Ping timeouts are not detected

PINREQs seem to be sent correctly, but for reliability's sake it would be good to raise a connection error if a PINGRESP isn't received in response to a PINGREQ.

SSL/TLS connection to the broker

Hi,

Is SSL/TLS is supported in QMQTT or not yet ?
How can we use it and set certificate and other information ? Is there an example ?

Regards,
Mohamed

unresolved symbol in message router

I am using Qt 5.4.1 at the moment.

You are using "QLoggingCategory" (https://github.com/emqtt/qmqtt/blob/4406d6f6b5352dcc796970c65da0d6e7e963e1cd/qmqtt_client_p.h#L40). This class was introduced in Qt 5.2 (http://doc.qt.io/qt-5/qloggingcategory.html), so I am using Qt5, not Qt4.

If I add a main to the current source code and compile it as an application, I get an error about unresolved symbols.

The error complains missing "routeMessage" a slot defined for RouteSubscription.
b9ef8e4#diff-8fd9f2b86c31347db2c08db95731b25dR69

I have a look at the moc output and it seems that only the first class containing Q_OBJECT is evaluated.

I never mixed multiple classes that use the qt meta system in one header file.
Is this common practice now?

Mqtt

Hi.I can't compile this.Please help me

autoReconnect doesn't do anything

As far as I can tell this property exists in the public interface but it's never used for anything. It's not documented in the README but it's been there for a year - is this unfinished?

Messages are not sent when compiling with Qt 5.7 on ARM

It seems that the client is connecting, it pushes the messages (says successfully sent), however, we cant get them on another MQTT client.
Strangely, when we compile with Qt 5.2, we do receive the messages.
Can provide full log if needed.

cannot connect to MQTT broker

Hi I am using CloudMQTT as the MQTT broker
I have a username and password to access.
My code looks like following
QMQTT::Client *client = new QMQTT::Client();
client->setUsername("username");
client->setPassword("password");
client->setHostName("mqtt://m11.cloudmqtt.com");
client->setPort(port);
client->connectToHost();
client->connectionState() (This returns 0)

Why could this be happening
What is the best way to specify hostname?

Thanks,
Sarang

QMQTT with websockets

I have setup eMQTT in windows I am using QMQTT for subscription and publishing.

Everything works like a charm.

My problem is how to use websocket with QMQTT Client.

There are no methods in QMQTT::Client which accepts URL.

I tried to use hostname,/host address with port 8083 default for ws port for broker but not able to connect.

Can anybody help me in this?
Seems like I am doing something wrong.

Bus error

HI
I try run QMQTT.
My code:
`
this->client = new QMQTT::Client("192.168.10.93", 8883, true, true); //SSL

 this->client->setClientId(QString(QUuid::createUuid().toString()));

 this->client->setUsername("*****");

 this->client->setPassword("*****");

 //this->client->connect();

 this->client->connectToHost();

Or I try:
client = new QMQTT::Client("192.168.10.93", 8883, true, true); //SSL

client->setClientId("Piec");

client->setUsername("****");

client->setPassword("*****");

client->setHostName("192.168.10.93");

client->connectToHost();

`

But I get always the same error when I run my app.

Bus error

Any suggestions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.