Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QSslSocket blocks webserver response delivery



  • I am building an IoT device which uses MQTT over SSL and during setup the user opens an access point and python flask webserver to configure the device. The main application is written with Qt (5.12.3) and maintains the MQTT connection. The application continously tries to establish connection to the broker if no ping was received for 15 seconds. The restablishing of the connection is done like this (for brevity sake I removed the setup stuff):

                m_ssl_socket->disconnectFromHost();
                m_ssl_socket->abort();
                m_ssl_socket->connectToHostEncrypted(Config::getMqttEndpoint(), Config::getMqttPort());
                m_ssl_socket->waitForEncrypted(1000);
                if(m_ssl_socket->isEncrypted() && m_mqtt_client){
                    m_mqtt_client->connectToHostEncrypted();
                }
    

    I can see that the python webserver stops responding when the m_ssl_socket changes into the HostLookupState. This state is maintained for an unusal long time >20 seconds if the device has no internet connectivity and the lookup fails. Is there a way to setup a timeout for the hostlookup? I could not find anything on the QSslSocket class and the QAbstractSocket. Reading the source code of QtBase left me more confused then before.

    I am working on providing a full minimal example.


Log in to reply