-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
CONNECT through HTTP proxy causes 100% CPU load #7589
Comments
I cannot reproduce. |
That doesn't happen for me. |
I tried it a few times but it times out. |
I have this same problem using curl with proxies in PHP (curl version 7.78.0), on the command line of the server I have an older version of curl and this problem does not happen (7.29.0). This problem is exacerbated when the proxy is down, running for several seconds at 100% cpu. Curl comand line (Version 7.29.0), this works fine and returns the answer immediately.
PHP Curl (Version 7.78.0), this hangs for several seconds, with the cpu at 100%, more below I have the output of strace when it is at 100%.
If I run strace
|
I leave also the Without proxy
With proxy
|
@ollm even more interesting for us is steps to reproduce this. |
This is the PHP code with which I have been tested and with which the problem also occurs (My code in production is different), the nordVPN username and password is not necessary, since this specific server is down, even so the error occurs anyway. $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.google.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Proxy
curl_setopt($ch, CURLOPT_PROXY, 'es137.nordvpn.com:89');
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTPS);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'xx:xx');
curl_setopt($ch, CURLOPT_HEADER, true);
// Verbose
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_STDERR, fopen('./curl_debug.txt', 'w'));
$html = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$curl_errno = curl_errno($ch);
curl_close($ch);
var_dump($curl_errno);
var_dump($html); I have not tried it on the command line since the curl version is different, but the code would be the following.
|
I have tried this curl binary on my computer and the problem also happens: https://github.com/moparisthebest/static-curl/releases/download/v7.78.0/curl-amd64 from https://github.com/moparisthebest/static-curl/releases/tag/v7.78.0
|
Otherwise it would wait socket writability even after the entire CONNECT request has sent and make curl basically busy-loop while waiting for a response to come back. The previous fix attempt in #7484 (c27a70a) was inadequate. Reported-by: zloi-user on github Reported-by: Oleguer Llopart Fixes #7589
Please test #7647 |
It works much better, even so it still takes 15 seconds to finish (I don't know if this is intentional), the version I have on the server (7.29.0) returns an almost instantaneous response with the error Tests proxy down
master bagder/connect-getsock Tests proxy that is not down
master bagder/connect-getsock Test without proxy
master |
@ollm you're now conflating several issues into one. This issue is about spending 100% CPU during the CONNECT procedure and that's what I believe my PR fixes. There might be more issues, but I would urge you to file and work on them separately. |
Does it receive the 407 error much faster then or what makes it abort so fast? |
No wait. 7.29.0 didn't support HTTPS proxies at all, so of course it failed fast! |
Sorry, I didn't know that curl 7.29.0 didn't support HTTPS proxies. Thanks for the fix. |
#7155 - the problem is not solved, curl still loads the cpu
on version 7.76.1, the problem is not observed, all versions after loading the cpu 100%
while true;do curl --proxy 'http://51.81.82.175:2003' 'https://www.google.com/favicon.ico' -o - >>/dev/null; done
The text was updated successfully, but these errors were encountered: