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. How to reuse QNetworkReply to use HTTP Persistent Connection?

How to reuse QNetworkReply to use HTTP Persistent Connection?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 2.1k 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.
  • W Offline
    W Offline
    wqking
    wrote on 19 Dec 2015, 13:17 last edited by wqking
    #1

    Hi all,

    I have an application that accesses REST API from a server. The server limits new connection count to 2 each second. But it allows more requests in a single connection (HTTP persistent connection).

    I use QNetworkReply and QNetworkAccessManager. Qt 5.4.

    From what I read, by default Qt network uses persistent connection. However, the connection will be closed when a reply is deleted.

    My question is, how to reuse QNetworkReply wihout deleting it and create new one for each request? Since I access REST API, there are a lot of different kinds of request with different parameters and request type (get, post, delete, etc). Seems the only way to create and config QNetworkReply is calling QNetworkAccessManager get/post/deleteResource methods. How can I feed different parameters and request type to an existing QNetworkReply?

    Thanks

    My personal website https://www.kbasm.com/
    My Github https://github.com/wqking

    1 Reply Last reply
    0
    • W Offline
      W Offline
      wqking
      wrote on 21 Dec 2015, 02:11 last edited by
      #2

      Nobody? I'm thinking about to switch to libcurl with which I can control everything...

      My personal website https://www.kbasm.com/
      My Github https://github.com/wqking

      1 Reply Last reply
      0
      • R Offline
        R Offline
        raven-worx
        Moderators
        wrote on 21 Dec 2015, 09:51 last edited by
        #3

        Maybe the server sends a CLOSE response anyways. Some server implementations do not honor the keep-alive request correctly.
        you can try if libcurl is working at all?
        Also maybe you can sniff the data transfer (especially the request and response headers)?

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        W 1 Reply Last reply 21 Dec 2015, 10:41
        0
        • R raven-worx
          21 Dec 2015, 09:51

          Maybe the server sends a CLOSE response anyways. Some server implementations do not honor the keep-alive request correctly.
          you can try if libcurl is working at all?
          Also maybe you can sniff the data transfer (especially the request and response headers)?

          W Offline
          W Offline
          wqking
          wrote on 21 Dec 2015, 10:41 last edited by
          #4

          @raven-worx said:

          Maybe the server sends a CLOSE response anyways. Some server implementations do not honor the keep-alive request correctly.
          you can try if libcurl is working at all?
          Also maybe you can sniff the data transfer (especially the request and response headers)?

          The problem is not persistent connection doesn't work, but deleting a QNetworkReply will cause the connection closed. I'm looking for how to reuse existing QNetworkReply.
          Currently when I need a QNetworkReply, I have to call QNetworkAccessManager get/post/deleteResource methods to create a new reply, seems no way to reuse a reply.

          My personal website https://www.kbasm.com/
          My Github https://github.com/wqking

          1 Reply Last reply
          0
          • R Offline
            R Offline
            raven-worx
            Moderators
            wrote on 21 Dec 2015, 11:36 last edited by
            #5

            because this simply makes no sense to reuse a REPLY, since a REPLY is the RESPONSE to a single REQUEST.
            As i said...check the request- and repsonse-headers and see if the webserver even supports a persistent connection properly.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0

            1/5

            19 Dec 2015, 13:17

            • Login

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