Note that there are some explanatory texts on larger screens.

plurals
  1. POQTimer timeout problems with QEventLoop and QNAM
    text
    copied!<p>I have created my own HTTP class that utilizes QNAM and provides means for sending HTTP requests. It uses QEventLoop for synchronization and QTimer for timeouts.</p> <p>I'm facing few problems with my solution. On certain Symbian platforms my QTimer signals timeout too fast (e.g. like after 1 sec when timeout is 30 secs). This happends usually if my HTTP Post playload is large or if I'm downloading a file via GET (request takes some time to complete). I want to note that same code works fine on certain devices (S60 3rd ed.) but on the other hand some devices (5th edition) get this error almost all the time.</p> <p>Here is a code snippet:</p> <pre><code>MyHttp::MyHttp(QObject *parent) : QObject(parent) { m_Timer.setSingleShot(true); connect(&amp;m_Manager, SIGNAL(finished(QNetworkReply*)), SLOT(OnFinished(QNetworkReply*))); connect(&amp;m_Timer, SIGNAL(timeout()), SLOT(OnTimeout())); } void MyHttp::Post(const QString &amp;data) { m_RetCode = 0; QNetworkRequest request(url); m_Reply = m_Manager.post(request, data.toAscii()); // QPointer&lt;QNetworkReply&gt; m_Reply m_Timer.start(30*1000); m_EventLoop.exec(); // Synchronization point } void MyHttp::OnFinished(QNetworkReply * reply) { // Handle response / Timeout / Errors reply-&gt;deleteLater(); // Use deleteLater() as adviced in the documentation StopWaiting(); } void MyHttp::StopWaiting() { m_Timer.stop(); m_EventLoop.exit(); } void MyHttp::OnTimeout() { m_RetCode = TIMEOUT; // #define TIMEOUT 50000 if(m_Reply.isNull() == false) { // Abort reply m_Reply-&gt;abort(); } } </code></pre> <p>Personally I think that one of the following might cause the problem:</p> <ul> <li>re-entering local event loop messes up the signals</li> <li>I'm utilizing same QNAM multiple times (several request during same session). This is required because if I destroy the QNAM my session goes down on the server side.</li> </ul> <p>Is anyone able to see some errors that might cause this behavior?</p> <p>Platform: Symbian S60 3rd/5th edition</p> <p>Tools: Nokia Qt SDK </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload