Details
-
Suggestion
-
Resolution: Incomplete
-
P3: Somewhat important
-
None
-
5.11
-
None
-
Suse 42.3
gcc v7.2.1
Description
The QMqttClient class defines enum TransportType { IODevice, AbstractSocket, SecureSocket }.
For a QIODevice, the QMqttClient will check to see if the 'transport' isOpen() and when not, QIODevice->open() will be called.
Immediately after that, MqttClient will send the mqtt credentials via sendControlConnect().
The WebSockets MQTT Subscription example internally uses a WebSocketIODevice class that is a QIODevice and has a QWebSocket. The open() method will open the QWebSocket and send out a QNetworkRequest to setup the websocket. The open() call will return immediately, but the QWebSocket will not be usable until the socket is actually connected, which then triggers QMqttClient to send the credentials.
When the example code is based on QIODevice, the code should probably reflect / emphasize that the device setup should be finished before providing it to the QMqttClient.
See also QTBUG-66955