-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CURLMOPT_MAX_TOTAL_CONNECTIONS seems to be ignored #15857
Comments
According to the logs (at the end of flightrecorder.log), it looks like curl had one HTTP/2 connection (no. 109) idle for a long time.
But curl started to open new connections for every upcoming requests and connection limit was surpassed before the too old connection was closed properly.
|
The feature that was introduced in 8.9.0 is improved connection shutdown, especially for connections that involve TLS. For this, a separate list of connections in shutdown is kept at curl's connection pool. These do not count against the Would this explain the effects you are seeing? Since the logs are huge, it might help analysing them if you traced curl's connection and transfer ids with it (the |
The option is not a limit of number of sockets used. It is a limit of number of connections done at any one time. |
Hi @icing, I suppose the feature you mentioned is causing us issue, because the number of opened sockets by libcurl never exceeded CURLMOPT_MAX_TOTAL_CONNECTIONS limit before. The software which uses libcurl statically reserves 8 IO event handler to handle the read/write events for curl sockets.
I don't know if you could follow my thought or not, never mind. PS: about the logs: |
First: number of sockets != number of connections. curl may use more sockets than connections. Then: I think we should improve libcurl in this regard. A set maximum number of connections should be acknowledged and respected even if some of them are held for disconnect. I think that's what users want when they set the limit. The main question is how... |
Hi @baranyaib90, thanks for the explanation. I can see how the change in connection shutdown handling affects your application. Though, as @bagder said, it was never intended to limit the number of sockets, it worked like that in the past for you. FYI: the "magical" shutdown was introduced for other use cases where libcurl caused TCP RST conditions before. That negatively affected other libcurl applications. @bagder, I think we could change the limit handling to include connections in shutdown (the easy part), but making the resumptions of idle transfers work reliably when the connection really goes away, it the more tricky part. |
I made #15879 as a proposed change to count shutdown connections against the destination limit. I would be great if you could test this in your scenario. |
@icing just note that @baranyaib90's issue here is using the total connection count, not the one per host. |
Ah, will adjust. |
Added the changes for total limit to #15879 and added test cases and verification. |
A few curl version after 8.9.0 kept connections opened which did not count in CURLMOPT_MAX_TOTAL_CONNECTIONS limit. Therefore more IO events are necessary to handle more sockets than we expect. Details in: curl/curl#15857
A few curl version after 8.9.0 kept connections opened which did not count in CURLMOPT_MAX_TOTAL_CONNECTIONS limit. Therefore more IO events are necessary to handle more sockets than we expect. Details in: curl/curl#15857
Hi! Thank you very much for your support! Much appreciated! |
I did this
I have set CURLMOPT_MAX_TOTAL_CONNECTIONS to 8.
I expected the following
That curl does not open more than 8 sockets, but it did.
curl/libcurl version
curl 8.9.1 (x86_64-pc-linux-gnu) libcurl/8.9.1 OpenSSL/3.3.1 zlib/1.3.1 brotli/1.1.0 zstd/1.5.6 libidn2/2.3.7 libpsl/0.21.2 libssh2/1.11.0 nghttp2/1.62.1 librtmp/2.3 OpenLDAP/2.6.8
Release-Date: 2024-07-31, security patched: 8.9.1-2ubuntu2.2
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp ws wss
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd
operating system
Ubuntu 24.10
Extra information
The text was updated successfully, but these errors were encountered: