Qt World Summit: Submit your Presentation


  • I have a simple program that spawns a couple of worker QThreads that make HTTP requests. Usually everything works fine, but every so often I get a QNetworkReply::ProtocolUnknownError on every single network request when I start the program.

    I dug into the QNetworkReply code a little and found that the error is coming from qnetworkreplyimpl.cpp line 81 and is triggered because the QNetworkAccessBackend pointer (backend) is NULL. I'm using Qt 4.7.1.

    Has anyone seen this error before or have any idea how to fix it?

  • Please, show you code, how do you use QNetworkReply?

  • The worker thread creates the QNetworkAccessManager. Basically it's:

    void MyWorkerThread::run()
    QNetworkAccessManager *nam = new QNetworkAccessManager();
    m_reply = nam->get(m_request);
    connect(m_reply, SIGNAL(finished()), this, SLOT(finishedRequest()), Qt::DirectConnection);
    connect(m_reply, SIGNAL(readyRead()), this, SLOT(dataReceived()), Qt::DirectConnection);

    // message loop until quit() is called
    delete nam;

    void MyWorkerThread::finishedRequest()
    m_error = m_reply->error();

  • Please, show your m_request creating and initialization.

  • The QNetworkRequst gets passed into the worker thread's constructor like:

    QNetworkRequest req(url);
    MyWorkerThread thread(req);

  • Why are you using threads at all? Don't make me link "my article":http://developer.qt.nokia.com/wiki/ThreadsEventsQObjects again and again :-) Adding slots to a QThread is very dangerous, not to mention forcing the connection type to Direct.

    Can you paste a full testcase? That is, a Short, Self Contained, Correct (Compilable), Example http://homepage1.nifty.com/algafield/sscce.html

Log in to reply