PDA

View Full Version : Count of QNetwork HTTP connections



mut
1st September 2016, 23:06
Hello

For the client side:


I want to know the maximum number of possible QNetwork HTTP connections (I'm using GET and POST) to a server?

How can I know the current number of active QNetwork HTTP connections that I have on my client?

How can I know the connection used by a particular QNetwork HTTP request?

How can I know the connection used by a particular QNetwork HTTP reply?

Thanks in advance.

Mut.

anda_skoa
2nd September 2016, 11:42
I want to know the maximum number of possible QNetwork HTTP connections (I'm using GET and POST) to a server?

I think a QNetworkAccessManager instance limits itself to 6 connections in total, not sure if it has an additional per-server limit.



How can I know the current number of active QNetwork HTTP connections that I have on my client?

You can guess an upper limit by taking the minimum of pending QNetworkReply objects and 6 * number of QNetworkAccessManager instances.
If you need to know the exact number you'll have to dig into QNetworkAccessManager's implementation



How can I know the connection used by a particular QNetwork HTTP request?

Not from the API, but of course you have the code so you are not necessarily limited by that.



How can I know the connection used by a particular QNetwork HTTP reply?

That's the same connection as the request, HTTP is a request/response protocol, it can't to reverse connections control/data channel dual connections.

Cheers,
_

mut
3rd September 2016, 03:49
Thanks for the replies. I'm focusing on the client side. What I want to know on the client (per ip address to the server) is which one of the below is correct:
1) Fixed pool of connections, a connection is immediately freed when unused and taken by new entrant
2) unlimited amount of connections, unused connections are kept alive for until time out period, hence connection count can grow quickly

You seems to indicate that that it is option 1, can you please reconfirm?

Could you please also be so kind as to elaborate on "QNetworkReply objects and 6 * number of QNetworkAccessManager instances."

Thanks

Mut

anda_skoa
3rd September 2016, 17:28
You seems to indicate that that it is option 1, can you please reconfirm?

From a cursory glance at the code that seems to be the case, yes.
Requests seem to be queued unless the current connection count is below the maximum threshold.



Could you please also be so kind as to elaborate on "QNetworkReply objects and 6 * number of QNetworkAccessManager instances."

If you have three active QNetworkReply objects, then you very likely have 3 connections.
If you have more than 6 on a single QNetworkAccessManager, then 6 would be the limit.

Cheers,
_

mut
6th September 2016, 05:17
Thanks again for the reply.

Are you saying that on the client side there is one QNetworkAccessManager per server ip?

Can you please confirm the below:
- Maximum is 6 connections per QNetworkAccessManager?
- If I have 9 QNetworkReply objects, 6 will be active and 3 will be queued?

Can you point me to the lines of the qt source code (5.5 or later) where queuing of connections occurs?

Mut

anda_skoa
6th September 2016, 11:11
Are you saying that on the client side there is one QNetworkAccessManager per server ip?

There are as many QNetworkAccessManager objects as you create.



Can you please confirm the below:
- Maximum is 6 connections per QNetworkAccessManager?

https://code.woboq.org/qt5/qtbase/src/network/access/qhttpnetworkconnection.cpp.html#_ZN29QHttpNetworkC onnectionPrivate23defaultHttpChannelCountE



- If I have 9 QNetworkReply objects, 6 will be active and 3 will be queued?

That would be my expectation.



Can you point me to the lines of the qt source code (5.5 or later) where queuing of connections occurs?

https://code.woboq.org/qt5/qtbase/src/network/access/qhttpnetworkconnection.cpp.html#_ZN22QHttpNetworkC onnection11sendRequestERK19QHttpNetworkRequest

Cheers,
_

mut
8th September 2016, 01:22
Thanks again. I m wondering if this maximum number of 6 connections can be adjusted and how to do that? Will adjusting it being safe and does not risk breaking qtnewtork?

anda_skoa
8th September 2016, 11:28
You'll have to check if the variable that gets initialized with the hard coded default count also appears in some setter somewhere.

If it does I am pretty sure that changing it doesn't impose any problems.

Changing the default and using a custom Qt version should also not be any problem.

Cheers,
_