Qt c++ application results QNetworkReply::UnknownNetworkError error after network restart
-
Hi there,
I am using Qt5.15 version for my application. My application is a basic server client application and with some custom features like monitoring wifi connection, in Linux. I am initializing a QNetworkAccessManager object to send and receive the data from my AWS server. The application runs without any issue until there is a network connectivity problem. If there is a network connectivity issue (wifi is not connected), I am restarting the network services using Linux commands. After the network is restarted, for the very first call to my AWS server, the QT debug prints are:
- Network error QNetworkReply::UnknownNetworkError received
(unknown:0) - QIODevice::read (QDisabledNetworkReply): device not openI tried to print the error code, and it was 99. I am not able to find the root cause and unable to make the API call pass. If I restart the application works. What should I do in the QT code to fix the application without restarting the same.
Looking forward to possible solutions.
Thanks. -
Hi and welcome to devnet,
What if you recreate your QNAM object ?
-
@SGaist Thanks for your response. I cannot create a new object for the QNAM. Because, the same object is being associated to different function. I would need to use the same object for the application. I couldn't get a proper example for re-initializing the QNAM object with the same object name. Could you please help me on that.
Thanks in Advance!
-
delete _qnam; _qnam = new QNetworkAccessManager(this); // do all the connections.
-