HTTP Pipelining in Qt?



  • I'm trying to implement http pipelining in Qt but I can't seem to get it working and there are no examples I can find on the internet. Currently my code looks like:

    slotDataReceived(QNetworkReply){
            --responsesPending
    
            // ... process reply...
    
            // Send more GET requests as needed
            while (responsesPending < maxPipelinedGets)          //maxPipelinedGets is set to 6
            {
                QUrl serverUrl;
                serverUrl.setHost(mAddress);
                serverUrl.setPort(mPort);
                serverUrl.setScheme("http");
                QNetworkRequest networkRequest(serverUrl);
                networkRequest.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
                networkRequest.setRawHeader("Host",mAddress.toLocal8Bit() + ":" + QString::number(mPort).toLocal8Bit());
                networkRequest.setRawHeader("Pragma", "no-cache");
                if(messageID != "")
                    networkRequest.setRawHeader("MsgID", messageID.toLocal8Bit());
    
                cout << "Sending HTTP GET request";
                networkManager->get(QNetworkRequest(*serverUrl));
                ++responsesPending;
            }
    }
    

    I still get responses from the server - but every time i get a response, 8 requests are sent, then 7 immediately come back with network reply errors, whilst one sits there waiting for another response, which suggests to me there is no http pipelining functionality present.

    If anyone could help direct me to a working solution that would be greatly appreciated! :)

    P.S. The server definitely supports pipelining - I have seen it working with straight C++.


  • Lifetime Qt Champion

    Hi,

    You might be hitting the limit number of connections in parallel that QNetworkAccessManager can do. It's described here.



  • @SGaist

    The limit number is 6 according to the description which is what my application is maxed to


  • Lifetime Qt Champion

    You can try using more QNAM bur in the end, creating many connection won't make it faster since you'll have a bottleneck with your connection's speed


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.