Unsolved 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 theHostLookupState
. 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 theQSslSocket
class and theQAbstractSocket
. Reading the source code ofQtBase
left me more confused then before.I am working on providing a full minimal example.