I try to send async multiple requests with proxy option by built-in WP Class Requests, but it's not working.

$options = array(
    'proxy' => $proxy

Single Request, it's working, so the proxy itself is working properly.

$s = Requests::request($link1, array(), array(), 'GET', $options);

The result of var_dump($s):

  public 'body' => string '<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for." name="description"><meta content="noodp" name="robots"><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png" itemprop="image"><title>Google</title><script>(fun'... (length=10134)
  public 'raw' => string 'HTTP/1.1 200 OK
Date: Fri, 17 Feb 2017 12:57:36 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
P3P: CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."
Content-Encoding: gzip
Server: gws
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Set-Cookie: NID=97=HAyw3oQtHmG8oehIO_MnRpi6jvwmLLwTjkWwOTZYAwa-m2oZfVzTEzqsmYEj-948Hw8HcMMSupEO79HQqUw96cgaYNj0_W_dj2e3w2Jn7C5lwH_xBJjepn5ssg1Ej6KUFJe'... (length=10834)
  public 'headers' => 

Multiple Requests, not working, always response connection time out error.

 $m = Requests::request_multiple(array(
         'url' => $link1
 ), $options);

The results of var_dump($m):

array (size=1)
  0 => 
      protected 'code' => int 28
      protected 'type' => string 'cURLEasy' (length=8)
      protected 'reason' => string 'Connection timed out after 10000 milliseconds' (length=45)
      protected 'data' => resource(1426, curl)
      protected 'message' => string '28 Connection timed out after 10000 milliseconds' (length=48)
      private 'string' (Exception) => string '' (length=0)
      protected 'file' => string '/Applications/MAMP/htdocs/wp/wp-includes/Requests/Transport/cURL.php' (length=68)
      protected 'line' => int 241
      private 'trace' (Exception) => 
        array (size=7)
          0 => 
            array (size=6)
              'file' => string '/Applications/MAMP/htdocs/wp/wp-includes/class-requests.php' (length=59)
              'line' => int 480
              'function' => string 'request_multiple' (length=16)
              'class' => string 'Requests_Transport_cURL' (length=23)
              'type' => string '->' (length=2)
              'args' => 
                array (size=2)
                  0 => 
                    array (size=1)
                      0 => 
                        array (size=5)
                  1 => 
                    array (size=20)
                      'timeout' => int 10
                      'connect_timeout' => int 10
                      'useragent' => string 'php-requests/1.7' (length=16)
                      'protocol_version' => float 1.1
                      'redirected' => int 0
                      'redirects' => int 10
                      'follow_redirects' => boolean true
                      'blocking' => boolean true
                      'type' => string 'GET' (length=3)
                      'filename' => boolean false
                      'auth' => boolean false
                      'proxy' => string '' (length=14)
                      'cookies' => boolean false
                      'max_bytes' => boolean false
                      'idn' => boolean true
                      'hooks' => null
                      'transport' => null
                      'verify' => string '/Applications/MAMP/htdocs/wp/wp-includes/certificates/ca-bundle.crt' (length=67)
                      'verifyname' => boolean true
                      'complete' => null

Did I missing anything? Does anyone have any suggestions? Thanks.

  • "Not working" says very little about the issue. Can you check what is returned by Requests::request_multiple()? You should get a Requests_Response or a Requests_Exception object with information about what happened. Can you share it with us? – cybmeta Feb 17 '17 at 10:30
  • @cybmeta Hi, thanks for reply. I just updated the debug info, I'm living in China and I can't access google without proxy, as you can see, the single request returned Requests_Response and multi requests returned Requests_Exception . – Cl0udSt0ne Feb 17 '17 at 13:08
  • @Cl0udSt0ne, the same for me, by not working , I guess he means that real ip is seen on destination server. Checking the docs request_multiple function , shows that proxy option is omitted. The bad thing is that options param is shared among request, so using different proxies for every request is not option with current implementation – Tebe Jun 16 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.