Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QTcpSocket/QMQTT - Strange Error Codes
g.hirsch last edited by g.hirsch
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 !
VRonin last edited by
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
Stoyan last edited by
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).
g.hirsch last edited by
I saw this old thread of mine and remembered, that the issue was solved. Just writing to explain how I solved it.
The problem was in the proxy settings. People who had their proxy configuration to automatic could connect, everyone else could not.
First solution was to set the configuration to automatic on every client. Which was cumbersome and seemed stupid, because the program does not need any proxy.
A little later I found out, that there was a problem with the Qt Network Interface, it was a known bug and could be worked around by telling the program manually to not use any proxy:
/* call before connecting to network. Easiest way is, just call somewhere at the beginning of the program */ QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);