F
F
Flysink2016-10-07 22:20:25
Multithreading
Flysink, 2016-10-07 22:20:25

Curl Multi socks5 proxy gives an error after the first troubles, why is it normal with http?

Windows 8
Apache 2.4
Php version 7
Curl version 7.50
I load http proxy 10 - 15k, I put any streams at least 1k checks quickly without errors, with socks5 another situation up to 200 pieces also checks perfectly, but after 200 or more, regardless of the number of streams, it issues error:

$multith = curl_multi_init(); 	
  foreach($proxys as $ip) {
    for($i=0; $i<count($ip); $i++) {
      $ch[$i] = curl_init();
      curl_setopt($ch[$i], CURLOPT_URL, $url);
      curl_setopt($ch[$i], CURLOPT_HEADER, true);         				 
      curl_setopt($ch[$i], CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
      curl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch[$i], CURLOPT_FOLLOWLOCATION, true);
      curl_setopt($ch[$i], CURLOPT_AUTOREFERER, true);
      curl_setopt($ch[$i], CURLOPT_CONNECTTIMEOUT, $timeout);
      curl_setopt($ch[$i], CURLOPT_TIMEOUT, $timeout);
      curl_setopt($ch[$i], CURLOPT_PROXY, $ip[$i]);
      curl_setopt($ch[$i], CURLOPT_VERBOSE, true);
      curl_setopt($ch[$i], CURLOPT_STDERR, $files);
      curl_setopt($ch[$i], CURLOPT_PROXYTYPE, type($proxytype));
      curl_setopt($ch[$i], CURLOPT_HTTPPROXYTUNNEL, true);
      curl_setopt($ch[$i], CURLOPT_NOBODY, true);
      curl_setopt($ch[$i], CURLOPT_SSL_VERIFYHOST,false);
      curl_setopt($ch[$i], CURLOPT_SSL_VERIFYPEER,false);
      curl_setopt($ch[$i], CURLOPT_FAILONERROR, true);
      curl_setopt($ch[$i], CURLOPT_POST, true);
      #curl_setopt($ch[$i], CURLOPT_PROXYUSERPWD, "login:pass");
      curl_multi_add_handle($multith,$ch[$i]);
    }
do {
      while($send = curl_multi_exec($multith,$run));
    } while($run == CURLM_CALL_MULTI_PERFORM);
      usleep(5000);
      while($run && $send == CURLM_OK) {
        if(curl_multi_select($multith) != -1) {
          do {
            $send = curl_multi_exec($multith,$run);
              while($result = curl_multi_info_read($multith)) {
                if($result['msg'] == CURLMSG_DONE) {
                  $getinfo = curl_getinfo($result['handle']);
                  $check = $getinfo['http_code']; 
                    if($check != 0) {
                      $count++;
                      echo $ip[array_search($result['handle'],$ch)].PHP_EOL;
                      flush();
                      ob_flush();
                      $ips = $ip[array_search($result['handle'],$ch)]."\r\n";
                      proxy_save(_FILE,$ips);
                      curl_multi_remove_handle($multith,$result['handle']);
                    }
                }
              }
              usleep(100);
          } 		while($run == CURLM_CALL_MULTI_PERFORM);
              usleep(100);
        }
      }
  }

* Trying 82.164.99.193...
* Trying 212.247.251.29...
* Trying 80.67.212.178...
* Trying 39.1.47.197...
* Trying 213.112.228.46...
* Trying 208.47.100.119...
* Trying 85.30.49.168...
* Trying 65.50.68.209...
* SOCKS5 read timeout
* Closing connection 1440
* Connection time-out
* Closing connection 1441
* Connection time-out
* Closing connection 1442
* Connection time-out
* Closing connection 1443
* SOCKS5 read timeout
* Closing connection 1444
* Unable to receive initial SOCKS5 response.
* Hostname mail.ru was found in DNS cache
the most interesting thing is if there are valid proxies at the beginning of the sox5 list, then it works out to the first trouble after one mistake.
There was a topic Checking Socks5 proxy through multi curl works badly. And HTTP proxies are perfect. Why is this happening? tried everything that was advised but it didn’t help
in google information very little all I found was old bug reports 5-6 years ago now because the version of curl is newer, maybe I’m doing something wrong, whoever encountered this will be glad for any help!
Ps if you check proxies without multi in single-threaded mode, it checks for a very long time but without errors

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2016-10-08
@dimonchik2013

just try to reduce version
https://curl.haxx.se/mail/tracker-2010-07/0061.html

V
Volodya771, 2017-05-30
@Volodya771

CURLOPT_HTTPPROXYTUNNEL this option only applies to http proxies, I don't know if this will help solve the problem, but you can try

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question