Results 1 to 7 of 7

Thread: Multiple QNetworkRequests (post) with QNetworkNetworkAccessManager in a loop

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2015
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Multiple QNetworkRequests (post) with QNetworkNetworkAccessManager in a loop

    Quote Originally Posted by ChrisW67 View Post
    As part of being a well-behaved netizen QNetworkAccessManager limits the number of simultaneous connections to a single server address. I am fairly sure this limit is 6 connections in the Qt5 source. Are all your connections to the same host?
    Thanks for responding.

    Only 1 host is concerned in this case. Is a new connection really created for every request in such a "batch" of 6? I don't think it explains why sometimes more than 6 requests (up to 11 observed so far) can be monitored on the network (and always the first n, no gaps in the sequence), do you have an explanation for this?

    Please note that my code is written in Qt 4.7. Thought I'd mention it since you talk about Qt5.

    Quote Originally Posted by yeye_olive View Post
    I do not understand all the details of your code, but something caught my attention. The line
    Qt Code:
    1. p->mReply = p->mManager->post(req, postReq);
    To copy to clipboard, switch view to plain text mode 
    overwrites the SyncPrivate's mReply member every time you send a request. Since all the requests made in the loop seem to go through the same Sync instance, I suppose that after the loop, mReply points to the last reply. Then, in Sync::replyFinished(), you always deal with that last reply, even if the slot is probably called for several of them. Here is a suggestion: instead of connecting to the QNetworkReply's finished() signal, consider connecting to QNetworkAccessManager::finished(QNetworkReply *) instead; that way, you get a pointer to the reply in the slot, right where you need it.
    Good point I guess. That would explain why the application only reports replies for some of the requests. Do you think this would influence the behaviour of sending the requests?

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Multiple QNetworkRequests (post) with QNetworkNetworkAccessManager in a loop

    Quote Originally Posted by TimWoo View Post
    Good point I guess. That would explain why the application only reports replies for some of the requests. Do you think this would influence the behaviour of sending the requests?
    I do not know the implementation details of QNetworkAccessManager, but it is entirely possible that the manager stops sending requests while too many QNetworkReply are around, waiting for the user to read their contents and then delete them.

  3. #3
    Join Date
    Mar 2015
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Multiple QNetworkRequests (post) with QNetworkNetworkAccessManager in a loop

    @ChrisW67
    Do you have any further insights?

    @yeye_olive
    I'm not familiar with the QNetworkAccessManager implementation myself, maybe someone else on the forum is? If so, I would very much welcome the input .

    Further:
    I cannot find any information about the maximum number of requests offered to QNetworkAccessManager simultaneously in the Qt 4.8 Documentation or anywhere else for that matter. I'm under the impression that it shouldn't be a problem for QNetworkAccessManager, but I could very well be wrong offcourse. It's all quite complex to me, as I'm still not quite familiar with asynchronous message handling.
    I'm currently tempted to prototype a workaround to see if offering 6 requests to the QNAM at the same time solves the problem. I would then wait sending the next 6 requests once the previous 6 have been processed.

    If anyone can shed some more light on the subject I would be very grateful.

    Best Regards,

    Tim

Similar Threads

  1. How to use for loop to check multiple number of objects
    By gunturrohith in forum Qt for Embedded and Mobile
    Replies: 5
    Last Post: 9th September 2015, 09:01
  2. add multiple QCoombox using loop
    By uz_qt in forum Qt Programming
    Replies: 8
    Last Post: 27th September 2013, 11:24
  3. Replies: 1
    Last Post: 18th April 2012, 07:47
  4. Replies: 4
    Last Post: 6th August 2011, 01:40
  5. Replies: 6
    Last Post: 25th May 2010, 10:42

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.