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. [Solved] QNetworkAccessManager empy reply next get fails
QtWS25 Last Chance

[Solved] QNetworkAccessManager empy reply next get fails

Scheduled Pinned Locked Moved General and Desktop
qnetworkaccessm
3 Posts 1 Posters 2.0k Views
  • 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.
  • L Offline
    L Offline
    LuGRU
    wrote on last edited by LuGRU
    #1

    Hello,
    I have a strange problem.
    I want to download XML (with is result of query from WWW) and situation looks like this:

    • 1st GET() request always success
    • next request do success when previous reply data is not empty
    • next request do FAIL when previous data is empty

    By fail I mean nothing happens at all. Checked with Wireshark and no GET request is send to WWW so Qt just fall-back silently (no finished(), progress() etc is emited, dead silence on QNetworkReply / QNetworkAccessManager).

    WWW uses basic authentication, on first connect attempt I do recive authenticationRequired(QNetworkReply*,QAuthenticator*) signal and after authentication everything works fine as long as server do reply with data.

    I'm open to any suggestion.
    NOTE: code is ok, because every other WWW do reply correctly so it seams to me that it's Qt bug similar to this one: https://bugreports.qt.io/browse/QTBUG-5997

    Thanks in advance for reply.
    Best regards

    UPDATE:
    More info about situation:

    • QNetworkAccessManager GET -> finished() -> reply->readAll() NOT empty
    • QNetworkAccessManager GET -> finished() -> reply->readAll() NOT empty
      ...
    • QNetworkAccessManager GET -> finished() -> reply->readAll() IS empty
    • QNetworkAccessManager GET -> dead silence nothing happens at this point using reply->abort(); reply->close() nothing works. No finished() / progress() etc.
    1 Reply Last reply
    0
    • L Offline
      L Offline
      LuGRU
      wrote on last edited by LuGRU
      #2

      In free time I did more research and server reply with HTTP status 204. After receiving 204 next GET request does nothing.

      Update:
      situation 1
      QNetworkAccessManager ->get() ... reply HTTP 200
      QNetworkAccessManager ->get() ... reply HTTP 204
      QNetworkAccessManager ->get() ... nothing

      situation 2
      QNetworkAccessManager ->get() ... reply HTTP 204
      QNetworkAccessManager ->get() ... nothing

      So when QNetworkAccessManager get 204 next get() will fail.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        LuGRU
        wrote on last edited by
        #3

        Solution:
        There is something wrong with QNetworkAccessManager when HTTP 204 reply ("No content") is received. Probably timeout or internal connection state is not updated (i.e. class still thinks that connection / reply did not finished).

        To get around this don't use persistent connection Keep-alive but close each time.

            QNetworkRequest request;
            request.setUrl( url);
            ...
            request.setRawHeader("Connection", "close");
        
        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