Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QNetworkReply::ProtocolUnknownError
Forum Updated to NodeBB v4.3 + New Features

QNetworkReply::ProtocolUnknownError

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 6.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jmenter
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vsorokin
      wrote on last edited by
      #2

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

      --
      Vasiliy

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jmenter
        wrote on last edited by
        #3

        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
        exec();
        delete nam;
        }

        void MyWorkerThread::finishedRequest()
        {
        m_error = m_reply->error();
        quit();
        }@

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vsorokin
          wrote on last edited by
          #4

          Please, show your m_request creating and initialization.

          --
          Vasiliy

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jmenter
            wrote on last edited by
            #5

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

            @
            QNetworkRequest req(url);
            MyWorkerThread thread(req);
            thread.start();
            @

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dangelog
              wrote on last edited by
              #6

              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

              Software Engineer
              KDAB (UK) Ltd., a KDAB Group company

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved