QTcpSocket/QMQTT - Strange Error Codes
I'm using Qt 5.9.1 on a Windows 10 machine and develop a program which can control shutters through MQTT-Messages for other Windows 10 machines.
For the MQTT part I use a client which I found on GitHub (https://github.com/emqtt/qmqtt). The program works perfectly fine on my machine.
The progam has one big problem: it does not run on every machine (statistically on 1/3 of all tested machines). I'm having some debug output on a console window, which gives me an error on the machines that don't work.
There are only two ocurring errors:
- QMQTT::SocketUnsupportedSocketOperationError (QAbstractSocket::UnsupportedSocketOperationError)
- QMQTT::SocketAccessError (QAbstractSocket::SocketAccessError)
In the program the error has the type QMQTT::ClientError, which is a "copy" of the QAbstractSocket::SocketError type. The errors already occur after I call the connectToHost() method of the QMQTT-Client.
QMQTT::Client client(QHostAddress("192.168.8.130"), 1883); // set username etc. // connect error signal to a function to print errors client.connectToHost();
What I already did:
I followed the
QMQTT::Client::connectToHost()slot in the source code and got to a point where the
QTcpSocket::connectToHost()method is called. I added a console ouput before this call. If a machine, that does not work, runs this program it gets the output and right after that follows the error message.
A further point tells me that the problem has to do something with the user directory.
To dig even deeper, I figured out that the problem is connected to the NTUSER.DAT file inside the users home directory. If the file gets renamed and the user relogs into his account, he gets a brand new NTUSER.DAT file and my program runs with zero errors occuring. When he uses his old NTUSER.DAT again, the programs stops working. It also works when a new profile runs the program.
I glimpsed into the
QTcpSocketsource code and was able to connect some Windows Errors to my ocurring Qt Errors. In the Microsoft Documentation I found the meaning for those Errors but they don't seem to fit in the picture
I hope someone can help me with this problem. For now my best option seems to be to look forward for Qt 5.10 an the MQTT-Client that ships with it but thats to much time for just waiting.
Thanks in advance !
NTUSER.DAT is the windows registry. it looks like you have a key set that shuts down your program. This does not sound like a Qt-related issue
I'm not sure, but you can change port number 1883 to something else and check again. It's possible on some systems this port to be in use.
By the way, first error means this:
The requested socket operation is not supported by the local operating system (e.g., lack of IPv6 support).