Advagg work fine, all my CSS and JS files are grouped in two files, and I have a lot, 40 CSS and 47 JS files

<link type="text/css" rel="stylesheet" media="all" href="/sites/default/files/advagg_css/css_15ef00e9abd021ebcfae51f2630534a5_0.css"/>
<script type="text/javascript" src="/sites/default/files/advagg_js/js_7731abe2e0b5817cf82e701c67baa84c_0.js"></script>

But I'm experimenting problems when open the admin pages: admin/reports/status or admin/settings/advagg that freeze the site (not the server). That pages never open and from that lapse of time (1min or 2) any user can't open any other page.

I notice that the problem is when use FastCGI, if I enable and disable this the problem appear and disapear.

Let me know if you need more information to resolve this

thanks

Comments

mikeytown2’s picture

Do you have this same issue when using HTTPRL?

RAFA3L’s picture

I get this on the admin/reports/status page, maybe I need check the php 5.3.5 configuration. I can see this error only using Apache module instead of Fastcgi because using Fastcgi the admin pages never load.

HTTPRL - Non Blocking	This server does not handle hanging connections.
Using non blocking mode on this server my not work correctly. More info: Array
(
    [0] => Array
        (
            [count] => 1
            [time] => 6019.73
        )

    [1] => Array
        (
            [http://mydomain.com/prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_cf56ceb83f1a65bf441f673bb9e5fdec] => stdClass Object
                (
                    [url] => http://mydomain.com/prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_cf56ceb83f1a65bf441f673bb9e5fdec
                    [request] => GET /prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_cf56ceb83f1a65bf441f673bb9e5fdec HTTP/1.0
Host: mydomain.com
User-Agent: Drupal (+http://drupal.org/)
Connection: close
Referer: http://mydomain.com/prueba/admin/reports/status


                    [status] => Non-Blocking request sent out. Not waiting for the response.
                    [data] => 
                    [options] => Array
                        (
                            [headers] => Array
                                (
                                    [Host] => mydomain.com
                                    [User-Agent] => Drupal (+http://drupal.org/)
                                    [Connection] => close
                                    [Referer] => http://mydomain.com/prueba/admin/reports/status
                                )

                            [blocking] => 
                            [timeout] => 6
                            [method] => GET
                            [data] => 
                            [max_redirects] => 3
                            [context] => 
                        )

                    [chunk_size] => 1024
                )

        )

    [2] => 
    [3] => 
)
mikeytown2’s picture

Is this with the latest dev of httprl?

RAFA3L’s picture

With the latest httprl dev version and advagg 6.x-1.6 all work perfect on apache module but when I change to fastcgi the problems come back

All the admin pages load after a long time

In admin/reports/status

Adv CSS/JS Agg - Asynchronous Mode Set to FALSE.

and

HTTPRL - Non Blocking	This server does not handle hanging connections.
Using non blocking mode on this server my not work correctly. More info: Array
(
    [0] => Array
        (
            [count] => 1
            [time] => 6103.36
        )

    [1] => Array
        (
            [http://mydomain.com/prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_ecd8d5b67ad2a4294ad69d6880f0a661] => stdClass Object
                (
                    [url] => http://mydomain.com/prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_ecd8d5b67ad2a4294ad69d6880f0a661
                    [request] => GET /prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_ecd8d5b67ad2a4294ad69d6880f0a661 HTTP/1
Host: mydomain.com
User-Agent: Drupal (+http://drupal.org/)
Connection: close
Referer: http://mydomain.com/prueba/admin/reports/status


                    [status] => Non-Blocking request sent out. Not waiting for the response.
                    [data] => 
                    [options] => Array
                        (
                            [headers] => Array
                                (
                                    [Host] => mydomain.com
                                    [User-Agent] => Drupal (+http://drupal.org/)
                                    [Connection] => close
                                    [Referer] => http://mydomain.com/prueba/admin/reports/status
                                )

                            [blocking] => 
                            [timeout] => 6
                            [method] => GET
                            [data] => 
                            [max_redirects] => 3
                            [context] => 
                            [version] => 1
                        )

                    [chunk_size] => 1024
                )

        )

    [2] => Array
        (
            [count] => 1
            [time] => 6010.14
        )

    [3] => Array
        (
            [http://myip/prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_1ee7887696b56a551372e6c65ee05ecb] => stdClass Object
                (
                    [url] => http://myip/prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_1ee7887696b56a551372e6c65ee05ecb
                    [request] => GET /prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_1ee7887696b56a551372e6c65ee05ecb HTTP/1
Host: mydomain.com
User-Agent: Drupal (+http://drupal.org/)
Connection: close
Referer: http://mydomain.com/prueba/admin/reports/status


                    [status] => Non-Blocking request sent out. Not waiting for the response.
                    [data] => 
                    [options] => Array
                        (
                            [headers] => Array
                                (
                                    [Host] => mydomain.com
                                    [User-Agent] => Drupal (+http://drupal.org/)
                                    [Connection] => close
                                    [Referer] => http://mydomain.com/prueba/admin/reports/status
                                )

                            [blocking] => 
                            [timeout] => 6
                            [method] => GET
                            [data] => 
                            [max_redirects] => 3
                            [context] => 
                            [version] => 1
                        )

                    [chunk_size] => 1024
                )

        )

)
mikeytown2’s picture

I wonder if FastCGI has issues with stream_select or with hanging connections. If your wondering HTTPRL is code that is inspired by AdvAgg; they both use the same principle thus just using HTTPRL will allow us to debug this faster.

Below is some debug code that I created from a quick copy paste from inside of
httprl_requirements(). If you could run it and report back the output that would be helpful.

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

ini_set('display_errors', TRUE);

    $url_path = 'admin/httprl-test';

    // Check that the menu router handler is working. If it's not working the rest
    // of the tests are pointless.
    $item = menu_get_item($url_path);


    // Test the non blocking url
    global $base_root, $base_path, $conf;
    $id = 'httprl_' . md5(mt_rand() . time());
    // Build URL to point to admin/httprl-test on this server.
    $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

    // Set the headers to point to this hostname.
    $headers = array(
      'Host' => $_SERVER['HTTP_HOST'],
    );

    // Add in the headers and set the blocking mode.
    $options = array(
      'headers' => $headers,
      'blocking' => FALSE,
      'timeout' => 6.0,
    );

    // Start the timer & Get a lock.
    timer_start($id);
    lock_acquire($id, 6);

    // Queue up the requests & execute them.
    httprl_request($url, $options);
    $requests = httprl_send_request();

    // Wait for the lock and stop the timer.
    lock_wait($id);
    $time = timer_stop($id);
    if (($time['time'] / 1000) > 5) {
      $ip = variable_get('httprl_server_addr', FALSE);
      $lasttime = '';
      $lastrequests = '';
      if (empty($ip)) {
        $lasttime = $time;
        $lastrequests = $requests;
        $conf['httprl_server_addr'] = -1;

        // If lock failed to release in time, try not using an IP when calling self.
        $id = 'httprl_' . md5(mt_rand() . time());
        // Build URL to point to admin/httprl-test on this server.


        $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

        // Set the headers to point to this hostname.
        $headers = array(
          'Host' => $_SERVER['HTTP_HOST'],
        );

        // Add in the headers and set the blocking mode.
        $options = array(
          'headers' => $headers,
          'blocking' => FALSE,
          'timeout' => 6.0,
        );

        // Start the timer & Get a lock.
        timer_start($id);
        lock_acquire($id, 6);

        // Queue up the requests & execute them.
        httprl_request($url, $options);
        $requests = httprl_send_request();

        // Wait for the lock and stop the timer.
        lock_wait($id);
        $time = timer_stop($id);
      }
      if (($time['time'] / 1000) > 5) {
        // Lock timed out and was not reset by the URL ping.
        $requirements['httprl_nonblocking'] = array('This server does not handle hanging connections.', $lastrequests, $requests);
      }
      else {
        $requirements['httprl_nonblocking'] = array('Semi-Works.', $lastrequests, $requests);
      }
    }
    else {
      $requirements['httprl_nonblocking'] = array('Works.', $requests);
    }



    $id = 'httprl_' . md5(mt_rand() . time());
    // Build URL to point to admin/httprl-test on this server.
    $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

    // Set the headers to point to this hostname.
    $headers = array(
      'Host' => $_SERVER['HTTP_HOST'],
    );

    // Add in the headers and set the blocking mode.
    $options = array(
      'headers' => $headers,
      'blocking' => TRUE,
      'timeout' => 6.0,
    );

    // Start the timer & Get a lock.
    timer_start($id);
    lock_acquire($id, 6);

    // Queue up the requests & execute them.
    httprl_request($url, $options);
    $requests = httprl_send_request();

    // Wait for the lock and stop the timer.
    lock_wait($id);
    $time = timer_stop($id);
    if (($time['time'] / 1000) > 5) {
      $ip = variable_get('httprl_server_addr', FALSE);
      $lasttime = '';
      $lastrequests = '';
      if (empty($ip)) {
        $lasttime = $time;
        $lastrequests = $requests;
        $conf['httprl_server_addr'] = -1;

        // If lock failed to release in time, try not using an IP when calling self.
        $id = 'httprl_' . md5(mt_rand() . time());
        // Build URL to point to admin/httprl-test on this server.


        $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

        // Set the headers to point to this hostname.
        $headers = array(
          'Host' => $_SERVER['HTTP_HOST'],
        );

        // Add in the headers and set the blocking mode.
        $options = array(
          'headers' => $headers,
          'blocking' => TRUE,
          'timeout' => 6.0,
        );

        // Start the timer & Get a lock.
        timer_start($id);
        lock_acquire($id, 6);

        // Queue up the requests & execute them.
        httprl_request($url, $options);
        $requests = httprl_send_request();

        // Wait for the lock and stop the timer.
        lock_wait($id);
        $time = timer_stop($id);
      }
      if (($time['time'] / 1000) > 5) {
        // Lock timed out and was not reset by the URL ping.
        $requirements['httprl_blocking'] = array('This server does not handle hanging connections.', $lastrequests, $requests);
      }
      else {
        $requirements['httprl_blocking'] = array('Semi-Works.', $lastrequests, $requests);
      }
    }
    else {
      $requirements['httprl_blocking'] = array('Works.', $requests);
    }

echo $_SERVER['GATEWAY_INTERFACE'];
echo str_replace('    ', '&nbsp;&nbsp;&nbsp;&nbsp;', nl2br(htmlentities(iconv('utf-8', 'utf-8//IGNORE', print_r($requirements, TRUE)), ENT_QUOTES, 'UTF-8')));

RAFA3L’s picture

I must change the line

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

to

require_once getcwd().'/includes/bootstrap.inc';

After that I get this code at the top of the page using Apache module

CGI/1.1Array
(
    [httprl_nonblocking] => Array
        (
            [0] => Works.
            [1] => Array
                (
                    [http://myip/prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_a566193c1158c22d1ed46ee9a4db27ac] => stdClass Object
                        (
                            [url] => http://myip/prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_a566193c1158c22d1ed46ee9a4db27ac
                            [request] => GET /prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_a566193c1158c22d1ed46ee9a4db27ac HTTP/1
Host: mydomain.com
User-Agent: Drupal (+http://drupal.org/)
Connection: close
Referer: http://mydomain.com/prueba/admin


                            [status] => Non-Blocking request sent out. Not waiting for the response.
                            [data] => 
                            [options] => Array
                                (
                                    [headers] => Array
                                        (
                                            [Host] => mydomain.com
                                            [User-Agent] => Drupal (+http://drupal.org/)
                                            [Connection] => close
                                            [Referer] => http://mydomain.com/prueba/admin
                                        )

                                    [blocking] => 
                                    [timeout] => 6
                                    [method] => GET
                                    [data] => 
                                    [max_redirects] => 3
                                    [context] => 
                                    [version] => 1
                                )

                            [chunk_size] => 1024
                        )

                )

        )

    [httprl_blocking] => Array
        (
            [0] => Works.
            [1] => Array
                (
                    [http://myip/prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_58f83139c6fd352e726d84b62e4f15c7] => stdClass Object
                        (
                            [url] => http://myip/prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_58f83139c6fd352e726d84b62e4f15c7
                            [request] => GET /prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_58f83139c6fd352e726d84b62e4f15c7 HTTP/1
Host: mydomain.com
User-Agent: Drupal (+http://drupal.org/)
Connection: close
Referer: http://mydomain.com/prueba/admin


                            [status] => Done.
                            [data] => lock httprl_58f83139c6fd352e726d84b62e4f15c7 cleared
                            [options] => Array
                                (
                                    [headers] => Array
                                        (
                                            [Host] => mydomain.com
                                            [User-Agent] => Drupal (+http://drupal.org/)
                                            [Connection] => close
                                            [Referer] => http://mydomain.com/prueba/admin
                                        )

                                    [blocking] => 1
                                    [timeout] => 6
                                    [method] => GET
                                    [data] => 
                                    [max_redirects] => 3
                                    [context] => 
                                    [version] => 1
                                )

                            [chunk_size] => 32768
                            [protocol] => HTTP/1.1
                            [status_message] => OK
                            [headers] => Array
                                (
                                    [date] => Fri, 16 Dec 2011 12:25:57 GMT
                                    [server] => Apache
                                    [x-powered-by] => PHP/5.3.5
                                    [expires] => Sun, 19 Nov 1978 05:00:00 GMT
                                    [cache-control] => store, no-cache, must-revalidate, post-check=0, pre-check=0
                                    [set-cookie] => SESS40e50a3fddb96038e1a8ba5fdc7b0732=b51c586a15b9dead246c778e8423fadf; expires=Sun, 08-Jan-2012 15:59:17 GMT; path=/; domain=.mydomain.com
                                    [last-modified] => Fri, 16 Dec 2011 12:25:57 GMT
                                    [vary] => Accept-Encoding
                                    [connection] => close
                                    [content-type] => text/html; charset=utf-8
                                )

                            [cookies] => Array
                                (
                                    [0] => Array
                                        (
                                            [name] => SESS40e50a3fddb96038e1a8ba5fdc7b0732
                                            [value] => b51c586a15b9dead246c778e8423fadf
                                            [expires] => Sun, 08-Jan-2012 15:59:17 GMT
                                            [path] => /
                                            [domain] => .mydomain.com
                                        )

                                )

                            [code] => 200
                        )

                )

        )

)

And using Fastcgi

CGI/1.1Array
(
    [httprl_nonblocking] => Array
        (
            [0] => This server does not handle hanging connections.
            [1] => Array
                (
                    [http://myip/prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_4f6af4ee7148f240f1cef947c9105db1] => stdClass Object
                        (
                            [url] => http://myip/prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_4f6af4ee7148f240f1cef947c9105db1
                            [request] => GET /prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_4f6af4ee7148f240f1cef947c9105db1 HTTP/1
Host: mydomain.com
User-Agent: Drupal (+http://drupal.org/)
Connection: close
Referer: http://mydomain.com/prueba/admin


                            [status] => Non-Blocking request sent out. Not waiting for the response.
                            [data] => 
                            [options] => Array
                                (
                                    [headers] => Array
                                        (
                                            [Host] => mydomain.com
                                            [User-Agent] => Drupal (+http://drupal.org/)
                                            [Connection] => close
                                            [Referer] => http://mydomain.com/prueba/admin
                                        )

                                    [blocking] => 
                                    [timeout] => 6
                                    [method] => GET
                                    [data] => 
                                    [max_redirects] => 3
                                    [context] => 
                                    [version] => 1
                                )

                            [chunk_size] => 1024
                        )

                )

            [2] => Array
                (
                    [http://mydomain.com/prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_911fb4ad751d6da9dd3ac1773512b157] => stdClass Object
                        (
                            [url] => http://mydomain.com/prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_911fb4ad751d6da9dd3ac1773512b157
                            [request] => GET /prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_911fb4ad751d6da9dd3ac1773512b157 HTTP/1
Host: mydomain.com
User-Agent: Drupal (+http://drupal.org/)
Connection: close
Referer: http://mydomain.com/prueba/admin


                            [status] => Non-Blocking request sent out. Not waiting for the response.
                            [data] => 
                            [options] => Array
                                (
                                    [headers] => Array
                                        (
                                            [Host] => mydomain.com
                                            [User-Agent] => Drupal (+http://drupal.org/)
                                            [Connection] => close
                                            [Referer] => http://mydomain.com/prueba/admin
                                        )

                                    [blocking] => 
                                    [timeout] => 6
                                    [method] => GET
                                    [data] => 
                                    [max_redirects] => 3
                                    [context] => 
                                    [version] => 1
                                )

                            [chunk_size] => 1024
                        )

                )

        )

    [httprl_blocking] => Array
        (
            [0] => This server does not handle hanging connections.
            [1] => 
            [2] => Array
                (
                    [http://mydomain.com/prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_9fec3b19ddaf35dd755fd0e27a277f36] => stdClass Object
                        (
                            [url] => http://mydomain.com/prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_9fec3b19ddaf35dd755fd0e27a277f36
                            [request] => GET /prueba/admin/httprl-test?key=423eae0630d68acd4014ae8fc1a40a1d&id=httprl_9fec3b19ddaf35dd755fd0e27a277f36 HTTP/1
Host: mydomain.com
User-Agent: Drupal (+http://drupal.org/)
Connection: close
Referer: http://mydomain.com/prueba/admin


                            [status] => Done.
                            [data] => 
                            [options] => Array
                                (
                                    [headers] => Array
                                        (
                                            [Host] => mydomain.com
                                            [User-Agent] => Drupal (+http://drupal.org/)
                                            [Connection] => close
                                            [Referer] => http://mydomain.com/prueba/admin
                                        )

                                    [blocking] => 1
                                    [timeout] => -0.0056799999999999
                                    [method] => GET
                                    [data] => 
                                    [max_redirects] => 3
                                    [context] => 
                                    [version] => 1
                                )

                            [chunk_size] => 1024
                            [error] => request timed out
                            [code] => -1
                        )

                )

        )

)
mikeytown2’s picture

Title: Problems with FastCGI » Problems with FastCGI & stream_select()

Sounds like FastCGI doesn't like stream_select(), I wonder if socket_select() will work. Will have to come up with an alt #1272542: fallback code for stream_select; cURL is next up. Do you have that installed on your server?

RAFA3L’s picture

Yes, MediaTemple has cURL installed

mikeytown2’s picture

cURL doesn't work with non blocking requests... so going to try fsockopen from Drupal 6's drupal_http_request. Can you test this code out?


define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

ini_set('display_errors', TRUE);
set_time_limit(0);


    $url_path = 'admin/httprl-test';

    // Check that the menu router handler is working. If it's not working the rest
    // of the tests are pointless.
    $item = menu_get_item($url_path);


    // Test the non blocking url
    global $base_root, $base_path, $conf;
    $id = 'httprl_' . md5(mt_rand() . time());
    // Build URL to point to admin/httprl-test on this server.
    $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

    // Set the headers to point to this hostname.
    $headers = array(
      'Host' => $_SERVER['HTTP_HOST'],
    );

    // Start the timer & Get a lock.
    timer_start($id);
    lock_acquire($id, 6);

    // Queue up the requests & execute them.
    nonblocking_drupal_http_request($url, $headers);

    // Wait for the lock and stop the timer.
    lock_wait($id);
    $time = timer_stop($id);
    if (($time['time'] / 1000) > 5) {
      $ip = variable_get('httprl_server_addr', FALSE);
      $lasttime = '';
      $lastrequests = '';
      if (empty($ip)) {
        $lasttime = $time;
        $lastrequests = $requests;
        $conf['httprl_server_addr'] = -1;

        // If lock failed to release in time, try not using an IP when calling self.
        $id = 'httprl_' . md5(mt_rand() . time());
        // Build URL to point to admin/httprl-test on this server.


        $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

        // Set the headers to point to this hostname.
        $headers = array(
          'Host' => $_SERVER['HTTP_HOST'],
        );

        // Start the timer & Get a lock.
        timer_start($id);
        lock_acquire($id, 6);

        // Queue up the requests & execute them.
        nonblocking_drupal_http_request($url, $headers);

        // Wait for the lock and stop the timer.
        lock_wait($id);
        $time = timer_stop($id);
      }
      if (($time['time'] / 1000) > 5) {
        // Lock timed out and was not reset by the URL ping.
        $requirements['httprl_nonblocking'] = array('This server does not handle hanging connections.', $lastrequests, $requests);
      }
      else {
        $requirements['httprl_nonblocking'] = array('Semi-Works.', $lastrequests, $requests);
      }
    }
    else {
      $requirements['httprl_nonblocking'] = array('Works.', $requests);
    }



    $id = 'httprl_' . md5(mt_rand() . time());
    // Build URL to point to admin/httprl-test on this server.
    $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

    // Set the headers to point to this hostname.
    $headers = array(
      'Host' => $_SERVER['HTTP_HOST'],
    );

    // Start the timer & Get a lock.
    timer_start($id);
    lock_acquire($id, 6);

    // Queue up the requests & execute them.
    nonblocking_drupal_http_request($url, $headers);

    // Wait for the lock and stop the timer.
    lock_wait($id);
    $time = timer_stop($id);
    if (($time['time'] / 1000) > 5) {
      $ip = variable_get('httprl_server_addr', FALSE);
      $lasttime = '';
      $lastrequests = '';
      if (empty($ip)) {
        $lasttime = $time;
        $lastrequests = $requests;
        $conf['httprl_server_addr'] = -1;

        // If lock failed to release in time, try not using an IP when calling self.
        $id = 'httprl_' . md5(mt_rand() . time());
        // Build URL to point to admin/httprl-test on this server.


        $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

        // Set the headers to point to this hostname.
        $headers = array(
          'Host' => $_SERVER['HTTP_HOST'],
        );

        // Start the timer & Get a lock.
        timer_start($id);
        lock_acquire($id, 6);

        // Queue up the requests & execute them.
        nonblocking_drupal_http_request($url, $headers);

        // Wait for the lock and stop the timer.
        lock_wait($id);
        $time = timer_stop($id);
      }
      if (($time['time'] / 1000) > 5) {
        // Lock timed out and was not reset by the URL ping.
        $requirements['httprl_blocking'] = array('This server does not handle hanging connections.', $lastrequests, $requests);
      }
      else {
        $requirements['httprl_blocking'] = array('Semi-Works.', $lastrequests, $requests);
      }
    }
    else {
      $requirements['httprl_blocking'] = array('Works.', $requests);
    }

echo $_SERVER['GATEWAY_INTERFACE'];
echo str_replace('    ', '&nbsp;&nbsp;&nbsp;&nbsp;', nl2br(htmlentities(iconv('utf-8', 'utf-8//IGNORE', print_r($requirements, TRUE)), ENT_QUOTES, 'UTF-8')));



/**
 * Perform an HTTP request.
 *
 * This is a flexible and powerful HTTP client implementation. Correctly handles
 * GET, POST, PUT or any other HTTP requests. Handles redirects.
 *
 * @param $url
 *   A string containing a fully qualified URI.
 * @param $headers
 *   An array containing an HTTP header => value pair.
 * @param $method
 *   A string defining the HTTP request to use.
 * @param $data
 *   A string containing data to include in the request.
 * @param $retry
 *   An integer representing how many times to retry the request in case of a
 *   redirect.
 * @return
 *   An object containing the HTTP request headers, response code, protocol,
 *   status message, headers, data and redirect status.
 */
function nonblocking_drupal_http_request($url, $headers = array(), $method = 'GET', $data = NULL, $retry = 3) {
  global $db_prefix;

  $result = new stdClass();

  // Parse the URL and make sure we can handle the schema.
  $uri = parse_url($url);

  if ($uri == FALSE) {
    $result->error = 'unable to parse URL';
    $result->code = -1001;
    return $result;
  }

  if (!isset($uri['scheme'])) {
    $result->error = 'missing schema';
    $result->code = -1002;
    return $result;
  }

  switch ($uri['scheme']) {
    case 'http':
    case 'feed':
      $port = isset($uri['port']) ? $uri['port'] : 80;
      $host = $uri['host'] . ($port != 80 ? ':'. $port : '');
      $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
      break;
    case 'https':
      // Note: Only works for PHP 4.3 compiled with OpenSSL.
      $port = isset($uri['port']) ? $uri['port'] : 443;
      $host = $uri['host'] . ($port != 443 ? ':'. $port : '');
      $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
      break;
    default:
      $result->error = 'invalid schema '. $uri['scheme'];
      $result->code = -1003;
      return $result;
  }

  // Make sure the socket opened properly.
  if (!$fp) {
    // When a network error occurs, we use a negative number so it does not
    // clash with the HTTP status codes.
    $result->code = -$errno;
    $result->error = trim($errstr);

    // Mark that this request failed. This will trigger a check of the web
    // server's ability to make outgoing HTTP requests the next time that
    // requirements checking is performed.
    // @see system_requirements()
    variable_set('drupal_http_request_fails', TRUE);

    return $result;
  }

  // Construct the path to act on.
  $path = isset($uri['path']) ? $uri['path'] : '/';
  if (isset($uri['query'])) {
    $path .= '?'. $uri['query'];
  }

  // Create HTTP request.
  $defaults = array(
    // RFC 2616: "non-standard ports MUST, default ports MAY be included".
    // We don't add the port to prevent from breaking rewrite rules checking the
    // host that do not take into account the port number.
    'Host' => "Host: $host",
    'User-Agent' => 'User-Agent: Drupal (+http://drupal.org/)',
  );

  // Only add Content-Length if we actually have any content or if it is a POST
  // or PUT request. Some non-standard servers get confused by Content-Length in
  // at least HEAD/GET requests, and Squid always requires Content-Length in
  // POST/PUT requests.
  $content_length = strlen($data);
  if ($content_length > 0 || $method == 'POST' || $method == 'PUT') {
    $defaults['Content-Length'] = 'Content-Length: '. $content_length;
  }

  // If the server url has a user then attempt to use basic authentication
  if (isset($uri['user'])) {
    $defaults['Authorization'] = 'Authorization: Basic '. base64_encode($uri['user'] . (!empty($uri['pass']) ? ":". $uri['pass'] : ''));
  }

  // If the database prefix is being used by SimpleTest to run the tests in a copied
  // database then set the user-agent header to the database prefix so that any
  // calls to other Drupal pages will run the SimpleTest prefixed database. The
  // user-agent is used to ensure that multiple testing sessions running at the
  // same time won't interfere with each other as they would if the database
  // prefix were stored statically in a file or database variable.
  if (is_string($db_prefix) && preg_match("/^simpletest\d+$/", $db_prefix, $matches)) {
    $defaults['User-Agent'] = 'User-Agent: ' . drupal_generate_test_ua($matches[0]);
  }

  foreach ($headers as $header => $value) {
    $defaults[$header] = $header .': '. $value;
  }

  $request = $method .' '. $path ." HTTP/1.0\r\n";
  $request .= implode("\r\n", $defaults);
  $request .= "\r\n\r\n";
  $request .= $data;

  $result->request = $request;

  fwrite($fp, $request);
  fclose($fp);

  return $result;
}
RAFA3L’s picture

Fatal error: Call to undefined function nonblocking_drupal_http_request() in /var/www/vhosts/mydomain.com/httpdocs/prueba/sites/all/modules/advagg/advagg.install on line 142

and the line is

nonblocking_drupal_http_request($url, $headers);

mikeytown2’s picture

How are you testing the code? I defined a new function called nonblocking_drupal_http_request in the code block above; and why is it inside of advagg.install? Copy the code block into something like test.php in the drupal web root, next to index.php.

RAFA3L’s picture

Sorry, in test.php with fastcgi module:

CGI/1.1Array
(
    [httprl_nonblocking] => Array
        (
            [0] => This server does not handle hanging connections.
            [1] => 
            [2] => 
        )

    [httprl_blocking] => Array
        (
            [0] => This server does not handle hanging connections.
            [1] => 
            [2] => 
        )

)

with apache

CGI/1.1Array
(
    [httprl_nonblocking] => Array
        (
            [0] => Works.
            [1] => 
        )

    [httprl_blocking] => Array
        (
            [0] => Works.
            [1] => 
        )

)
mikeytown2’s picture

Looks like FastCGI kills PHP when the connection is closed... I have 2 more tests for you to try:


define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

ini_set('display_errors', TRUE);
set_time_limit(0);


    $url_path = 'admin/httprl-test';

    // Check that the menu router handler is working. If it's not working the rest
    // of the tests are pointless.
    $item = menu_get_item($url_path);


    // Test the non blocking url
    global $base_root, $base_path, $conf;
    $id = 'httprl_' . md5(mt_rand() . time());
    // Build URL to point to admin/httprl-test on this server.
    $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

    // Set the headers to point to this hostname.
    $headers = array(
      'Host' => $_SERVER['HTTP_HOST'],
    );

    // Start the timer & Get a lock.
    timer_start($id);
    lock_acquire($id, 6);

    // Queue up the requests & execute them.
    nonblocking_drupal_http_request($url, $headers);

    // Wait for the lock and stop the timer.
    lock_wait($id);
    $time = timer_stop($id);
    if (($time['time'] / 1000) > 5) {
      $ip = variable_get('httprl_server_addr', FALSE);
      $lasttime = '';
      $lastrequests = '';
      if (empty($ip)) {
        $lasttime = $time;
        $lastrequests = $requests;
        $conf['httprl_server_addr'] = -1;

        // If lock failed to release in time, try not using an IP when calling self.
        $id = 'httprl_' . md5(mt_rand() . time());
        // Build URL to point to admin/httprl-test on this server.


        $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

        // Set the headers to point to this hostname.
        $headers = array(
          'Host' => $_SERVER['HTTP_HOST'],
        );

        // Start the timer & Get a lock.
        timer_start($id);
        lock_acquire($id, 6);

        // Queue up the requests & execute them.
        nonblocking_drupal_http_request($url, $headers);

        // Wait for the lock and stop the timer.
        lock_wait($id);
        $time = timer_stop($id);
      }
      if (($time['time'] / 1000) > 5) {
        // Lock timed out and was not reset by the URL ping.
        $requirements['httprl_nonblocking'] = array('This server does not handle hanging connections.', $lastrequests, $requests);
      }
      else {
        $requirements['httprl_nonblocking'] = array('Semi-Works.', $lastrequests, $requests);
      }
    }
    else {
      $requirements['httprl_nonblocking'] = array('Works.', $requests);
    }



    $id = 'httprl_' . md5(mt_rand() . time());
    // Build URL to point to admin/httprl-test on this server.
    $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

    // Set the headers to point to this hostname.
    $headers = array(
      'Host' => $_SERVER['HTTP_HOST'],
    );

    // Start the timer & Get a lock.
    timer_start($id);
    lock_acquire($id, 6);

    // Queue up the requests & execute them.
    nonblocking_drupal_http_request($url, $headers);

    // Wait for the lock and stop the timer.
    lock_wait($id);
    $time = timer_stop($id);
    if (($time['time'] / 1000) > 5) {
      $ip = variable_get('httprl_server_addr', FALSE);
      $lasttime = '';
      $lastrequests = '';
      if (empty($ip)) {
        $lasttime = $time;
        $lastrequests = $requests;
        $conf['httprl_server_addr'] = -1;

        // If lock failed to release in time, try not using an IP when calling self.
        $id = 'httprl_' . md5(mt_rand() . time());
        // Build URL to point to admin/httprl-test on this server.


        $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

        // Set the headers to point to this hostname.
        $headers = array(
          'Host' => $_SERVER['HTTP_HOST'],
        );

        // Start the timer & Get a lock.
        timer_start($id);
        lock_acquire($id, 6);

        // Queue up the requests & execute them.
        nonblocking_drupal_http_request($url, $headers);

        // Wait for the lock and stop the timer.
        lock_wait($id);
        $time = timer_stop($id);
      }
      if (($time['time'] / 1000) > 5) {
        // Lock timed out and was not reset by the URL ping.
        $requirements['httprl_blocking'] = array('This server does not handle hanging connections.', $lastrequests, $requests);
      }
      else {
        $requirements['httprl_blocking'] = array('Semi-Works.', $lastrequests, $requests);
      }
    }
    else {
      $requirements['httprl_blocking'] = array('Works.', $requests);
    }

echo $_SERVER['GATEWAY_INTERFACE'];
echo str_replace('    ', '&nbsp;&nbsp;&nbsp;&nbsp;', nl2br(htmlentities(iconv('utf-8', 'utf-8//IGNORE', print_r($requirements, TRUE)), ENT_QUOTES, 'UTF-8')));



/**
 * Perform an HTTP request.
 *
 * This is a flexible and powerful HTTP client implementation. Correctly handles
 * GET, POST, PUT or any other HTTP requests. Handles redirects.
 *
 * @param $url
 *   A string containing a fully qualified URI.
 * @param $headers
 *   An array containing an HTTP header => value pair.
 * @param $method
 *   A string defining the HTTP request to use.
 * @param $data
 *   A string containing data to include in the request.
 * @param $retry
 *   An integer representing how many times to retry the request in case of a
 *   redirect.
 * @return
 *   An object containing the HTTP request headers, response code, protocol,
 *   status message, headers, data and redirect status.
 */
function nonblocking_drupal_http_request($url, $headers = array(), $method = 'GET', $data = NULL, $retry = 3) {
  global $db_prefix;

  $result = new stdClass();

  // Parse the URL and make sure we can handle the schema.
  $uri = parse_url($url);

  if ($uri == FALSE) {
    $result->error = 'unable to parse URL';
    $result->code = -1001;
    return $result;
  }

  if (!isset($uri['scheme'])) {
    $result->error = 'missing schema';
    $result->code = -1002;
    return $result;
  }

  switch ($uri['scheme']) {
    case 'http':
    case 'feed':
      $port = isset($uri['port']) ? $uri['port'] : 80;
      $host = $uri['host'] . ($port != 80 ? ':'. $port : '');
      $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
      break;
    case 'https':
      // Note: Only works for PHP 4.3 compiled with OpenSSL.
      $port = isset($uri['port']) ? $uri['port'] : 443;
      $host = $uri['host'] . ($port != 443 ? ':'. $port : '');
      $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
      break;
    default:
      $result->error = 'invalid schema '. $uri['scheme'];
      $result->code = -1003;
      return $result;
  }

  // Make sure the socket opened properly.
  if (!$fp) {
    // When a network error occurs, we use a negative number so it does not
    // clash with the HTTP status codes.
    $result->code = -$errno;
    $result->error = trim($errstr);

    // Mark that this request failed. This will trigger a check of the web
    // server's ability to make outgoing HTTP requests the next time that
    // requirements checking is performed.
    // @see system_requirements()
    variable_set('drupal_http_request_fails', TRUE);

    return $result;
  }

  // Construct the path to act on.
  $path = isset($uri['path']) ? $uri['path'] : '/';
  if (isset($uri['query'])) {
    $path .= '?'. $uri['query'];
  }

  // Create HTTP request.
  $defaults = array(
    // RFC 2616: "non-standard ports MUST, default ports MAY be included".
    // We don't add the port to prevent from breaking rewrite rules checking the
    // host that do not take into account the port number.
    'Host' => "Host: $host",
    'User-Agent' => 'User-Agent: Drupal (+http://drupal.org/)',
  );

  // Only add Content-Length if we actually have any content or if it is a POST
  // or PUT request. Some non-standard servers get confused by Content-Length in
  // at least HEAD/GET requests, and Squid always requires Content-Length in
  // POST/PUT requests.
  $content_length = strlen($data);
  if ($content_length > 0 || $method == 'POST' || $method == 'PUT') {
    $defaults['Content-Length'] = 'Content-Length: '. $content_length;
  }

  // If the server url has a user then attempt to use basic authentication
  if (isset($uri['user'])) {
    $defaults['Authorization'] = 'Authorization: Basic '. base64_encode($uri['user'] . (!empty($uri['pass']) ? ":". $uri['pass'] : ''));
  }

  // If the database prefix is being used by SimpleTest to run the tests in a copied
  // database then set the user-agent header to the database prefix so that any
  // calls to other Drupal pages will run the SimpleTest prefixed database. The
  // user-agent is used to ensure that multiple testing sessions running at the
  // same time won't interfere with each other as they would if the database
  // prefix were stored statically in a file or database variable.
  if (is_string($db_prefix) && preg_match("/^simpletest\d+$/", $db_prefix, $matches)) {
    $defaults['User-Agent'] = 'User-Agent: ' . drupal_generate_test_ua($matches[0]);
  }

  foreach ($headers as $header => $value) {
    $defaults[$header] = $header .': '. $value;
  }

  $request = $method .' '. $path ." HTTP/1.0\r\n";
  $request .= implode("\r\n", $defaults);
  $request .= "\r\n\r\n";
  $request .= $data;

  $result->request = $request;

  fwrite($fp, $request);
  $result->data = fread($fp, 1024);
  fclose($fp);

  return $result;
}

define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

ini_set('display_errors', TRUE);
set_time_limit(0);


    $url_path = 'admin/httprl-test';

    // Check that the menu router handler is working. If it's not working the rest
    // of the tests are pointless.
    $item = menu_get_item($url_path);


    // Test the non blocking url
    global $base_root, $base_path, $conf;
    $id = 'httprl_' . md5(mt_rand() . time());
    // Build URL to point to admin/httprl-test on this server.
    $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

    // Set the headers to point to this hostname.
    $headers = array(
      'Host' => $_SERVER['HTTP_HOST'],
    );

    // Start the timer & Get a lock.
    timer_start($id);
    lock_acquire($id, 6);

    // Queue up the requests & execute them.
    nonblocking_drupal_http_request($url, $headers);

    // Wait for the lock and stop the timer.
    lock_wait($id);
    $time = timer_stop($id);
    if (($time['time'] / 1000) > 5) {
      $ip = variable_get('httprl_server_addr', FALSE);
      $lasttime = '';
      $lastrequests = '';
      if (empty($ip)) {
        $lasttime = $time;
        $lastrequests = $requests;
        $conf['httprl_server_addr'] = -1;

        // If lock failed to release in time, try not using an IP when calling self.
        $id = 'httprl_' . md5(mt_rand() . time());
        // Build URL to point to admin/httprl-test on this server.


        $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

        // Set the headers to point to this hostname.
        $headers = array(
          'Host' => $_SERVER['HTTP_HOST'],
        );

        // Start the timer & Get a lock.
        timer_start($id);
        lock_acquire($id, 6);

        // Queue up the requests & execute them.
        nonblocking_drupal_http_request($url, $headers);

        // Wait for the lock and stop the timer.
        lock_wait($id);
        $time = timer_stop($id);
      }
      if (($time['time'] / 1000) > 5) {
        // Lock timed out and was not reset by the URL ping.
        $requirements['httprl_nonblocking'] = array('This server does not handle hanging connections.', $lastrequests, $requests);
      }
      else {
        $requirements['httprl_nonblocking'] = array('Semi-Works.', $lastrequests, $requests);
      }
    }
    else {
      $requirements['httprl_nonblocking'] = array('Works.', $requests);
    }



    $id = 'httprl_' . md5(mt_rand() . time());
    // Build URL to point to admin/httprl-test on this server.
    $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

    // Set the headers to point to this hostname.
    $headers = array(
      'Host' => $_SERVER['HTTP_HOST'],
    );

    // Start the timer & Get a lock.
    timer_start($id);
    lock_acquire($id, 6);

    // Queue up the requests & execute them.
    nonblocking_drupal_http_request($url, $headers);

    // Wait for the lock and stop the timer.
    lock_wait($id);
    $time = timer_stop($id);
    if (($time['time'] / 1000) > 5) {
      $ip = variable_get('httprl_server_addr', FALSE);
      $lasttime = '';
      $lastrequests = '';
      if (empty($ip)) {
        $lasttime = $time;
        $lastrequests = $requests;
        $conf['httprl_server_addr'] = -1;

        // If lock failed to release in time, try not using an IP when calling self.
        $id = 'httprl_' . md5(mt_rand() . time());
        // Build URL to point to admin/httprl-test on this server.


        $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

        // Set the headers to point to this hostname.
        $headers = array(
          'Host' => $_SERVER['HTTP_HOST'],
        );

        // Start the timer & Get a lock.
        timer_start($id);
        lock_acquire($id, 6);

        // Queue up the requests & execute them.
        nonblocking_drupal_http_request($url, $headers);

        // Wait for the lock and stop the timer.
        lock_wait($id);
        $time = timer_stop($id);
      }
      if (($time['time'] / 1000) > 5) {
        // Lock timed out and was not reset by the URL ping.
        $requirements['httprl_blocking'] = array('This server does not handle hanging connections.', $lastrequests, $requests);
      }
      else {
        $requirements['httprl_blocking'] = array('Semi-Works.', $lastrequests, $requests);
      }
    }
    else {
      $requirements['httprl_blocking'] = array('Works.', $requests);
    }

echo $_SERVER['GATEWAY_INTERFACE'];
echo str_replace('    ', '&nbsp;&nbsp;&nbsp;&nbsp;', nl2br(htmlentities(iconv('utf-8', 'utf-8//IGNORE', print_r($requirements, TRUE)), ENT_QUOTES, 'UTF-8')));



/**
 * Perform an HTTP request.
 *
 * This is a flexible and powerful HTTP client implementation. Correctly handles
 * GET, POST, PUT or any other HTTP requests. Handles redirects.
 *
 * @param $url
 *   A string containing a fully qualified URI.
 * @param $headers
 *   An array containing an HTTP header => value pair.
 * @param $method
 *   A string defining the HTTP request to use.
 * @param $data
 *   A string containing data to include in the request.
 * @param $retry
 *   An integer representing how many times to retry the request in case of a
 *   redirect.
 * @return
 *   An object containing the HTTP request headers, response code, protocol,
 *   status message, headers, data and redirect status.
 */
function nonblocking_drupal_http_request($url, $headers = array(), $method = 'GET', $data = NULL, $retry = 3) {
  global $db_prefix;

  $result = new stdClass();

  // Parse the URL and make sure we can handle the schema.
  $uri = parse_url($url);

  if ($uri == FALSE) {
    $result->error = 'unable to parse URL';
    $result->code = -1001;
    return $result;
  }

  if (!isset($uri['scheme'])) {
    $result->error = 'missing schema';
    $result->code = -1002;
    return $result;
  }

  switch ($uri['scheme']) {
    case 'http':
    case 'feed':
      $port = isset($uri['port']) ? $uri['port'] : 80;
      $host = $uri['host'] . ($port != 80 ? ':'. $port : '');
      $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
      break;
    case 'https':
      // Note: Only works for PHP 4.3 compiled with OpenSSL.
      $port = isset($uri['port']) ? $uri['port'] : 443;
      $host = $uri['host'] . ($port != 443 ? ':'. $port : '');
      $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
      break;
    default:
      $result->error = 'invalid schema '. $uri['scheme'];
      $result->code = -1003;
      return $result;
  }

  // Make sure the socket opened properly.
  if (!$fp) {
    // When a network error occurs, we use a negative number so it does not
    // clash with the HTTP status codes.
    $result->code = -$errno;
    $result->error = trim($errstr);

    // Mark that this request failed. This will trigger a check of the web
    // server's ability to make outgoing HTTP requests the next time that
    // requirements checking is performed.
    // @see system_requirements()
    variable_set('drupal_http_request_fails', TRUE);

    return $result;
  }

  // Construct the path to act on.
  $path = isset($uri['path']) ? $uri['path'] : '/';
  if (isset($uri['query'])) {
    $path .= '?'. $uri['query'];
  }

  // Create HTTP request.
  $defaults = array(
    // RFC 2616: "non-standard ports MUST, default ports MAY be included".
    // We don't add the port to prevent from breaking rewrite rules checking the
    // host that do not take into account the port number.
    'Host' => "Host: $host",
    'User-Agent' => 'User-Agent: Drupal (+http://drupal.org/)',
  );

  // Only add Content-Length if we actually have any content or if it is a POST
  // or PUT request. Some non-standard servers get confused by Content-Length in
  // at least HEAD/GET requests, and Squid always requires Content-Length in
  // POST/PUT requests.
  $content_length = strlen($data);
  if ($content_length > 0 || $method == 'POST' || $method == 'PUT') {
    $defaults['Content-Length'] = 'Content-Length: '. $content_length;
  }

  // If the server url has a user then attempt to use basic authentication
  if (isset($uri['user'])) {
    $defaults['Authorization'] = 'Authorization: Basic '. base64_encode($uri['user'] . (!empty($uri['pass']) ? ":". $uri['pass'] : ''));
  }

  // If the database prefix is being used by SimpleTest to run the tests in a copied
  // database then set the user-agent header to the database prefix so that any
  // calls to other Drupal pages will run the SimpleTest prefixed database. The
  // user-agent is used to ensure that multiple testing sessions running at the
  // same time won't interfere with each other as they would if the database
  // prefix were stored statically in a file or database variable.
  if (is_string($db_prefix) && preg_match("/^simpletest\d+$/", $db_prefix, $matches)) {
    $defaults['User-Agent'] = 'User-Agent: ' . drupal_generate_test_ua($matches[0]);
  }

  foreach ($headers as $header => $value) {
    $defaults[$header] = $header .': '. $value;
  }

  $request = $method .' '. $path ." HTTP/1.0\r\n";
  $request .= implode("\r\n", $defaults);
  $request .= "\r\n\r\n";
  $request .= $data;

  $result->request = $request;

  fwrite($fp, $request);

  return $result;
}
RAFA3L’s picture

With test1

500 Internal Server Error

adn test2

CGI/1.1Array
(
[httprl_nonblocking] => Array
(
[0] => This server does not handle hanging connections.
[1] =>
[2] =>
)

[httprl_blocking] => Array
(
[0] => This server does not handle hanging connections.
[1] =>
[2] =>
)

)

mikeytown2’s picture

hmm lets try something a little more standard. This is using drupal_http_request(). Lets make sure this works. If this doesn't work then drupal wouldn't pass the system install requirements (system_check_http_request())


define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

ini_set('display_errors', TRUE);
set_time_limit(0);


    $url_path = 'admin/httprl-test';

    // Check that the menu router handler is working. If it's not working the rest
    // of the tests are pointless.
    $item = menu_get_item($url_path);


    // Test the non blocking url
    global $base_root, $base_path, $conf;
    $id = 'httprl_' . md5(mt_rand() . time());
    // Build URL to point to admin/httprl-test on this server.
    $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

    // Set the headers to point to this hostname.
    $headers = array(
      'Host' => $_SERVER['HTTP_HOST'],
    );

    // Start the timer & Get a lock.
    timer_start($id);
    lock_acquire($id, 6);

    // Queue up the requests & execute them.
    drupal_http_request($url, $headers);

    // Wait for the lock and stop the timer.
    lock_wait($id);
    $time = timer_stop($id);
    if (($time['time'] / 1000) > 5) {
      $ip = variable_get('httprl_server_addr', FALSE);
      $lasttime = '';
      $lastrequests = '';
      if (empty($ip)) {
        $lasttime = $time;
        $lastrequests = $requests;
        $conf['httprl_server_addr'] = -1;

        // If lock failed to release in time, try not using an IP when calling self.
        $id = 'httprl_' . md5(mt_rand() . time());
        // Build URL to point to admin/httprl-test on this server.


        $url = httprl_build_url_self($url_path . '?key=' . md5(drupal_get_private_key()) . '&id=' . $id, TRUE);

        // Set the headers to point to this hostname.
        $headers = array(
          'Host' => $_SERVER['HTTP_HOST'],
        );

        // Start the timer & Get a lock.
        timer_start($id);
        lock_acquire($id, 6);

        // Queue up the requests & execute them.
        drupal_http_request($url, $headers);

        // Wait for the lock and stop the timer.
        lock_wait($id);
        $time = timer_stop($id);
      }
      if (($time['time'] / 1000) > 5) {
        // Lock timed out and was not reset by the URL ping.
        $requirements['drupal_http_request'] = array('This server does not handle hanging connections.', $lastrequests, $requests);
      }
      else {
        $requirements['drupal_http_request'] = array('Semi-Works.', $lastrequests, $requests);
      }
    }
    else {
      $requirements['drupal_http_request'] = array('Works.', $requests);
    }


echo $_SERVER['GATEWAY_INTERFACE'];
echo str_replace('    ', '&nbsp;&nbsp;&nbsp;&nbsp;', nl2br(htmlentities(iconv('utf-8', 'utf-8//IGNORE', print_r($requirements, TRUE)), ENT_QUOTES, 'UTF-8')));
$x = system_check_http_request();
echo serialize($x);


RAFA3L’s picture

sorry by the delay, with the last code now I get a 500 internal server error after a long time trying to load

I put the code in a test.php file in the root of the drupal site.

Switching to the apache module I get

CGI/1.1Array
(
[drupal_http_request] => Array
(
[0] => Works.
[1] =>
)

)
b:1;

mikeytown2’s picture

What happens when you do this?

define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

ini_set('display_errors', TRUE);
set_time_limit(120);

$x = system_check_http_request();
echo serialize($x);

http://api.drupal.org/api/drupal/modules--system--system.module/function...

RAFA3L’s picture

With apache module:

b:1;

fastcgi:

b:0;

and long time to load

mikeytown2’s picture

There is something wrong with that setup (FastCGI) if Drupal Core doesn't work with it. This might help
http://drupal.org/node/588186
If it's still an issue I would jump on IRC and see what people say about how to fix it.

RAFA3L’s picture

You are right something is wrong with my server. I have a small VPS with 512 of ram and running a medium site with fastcgi to optimize the memory usage, this work perfect under fastcgi but without advagg, because the first time I install advagg the problem appear and I had to uninstall it. Now this site is working with Cloudflare only.

Now I was testing yours codes under another domain in the same server and I saw the same problem, even without using the advagg module. I did a new and fresh installation of drupal and I see that is running slow all what is inside the admin/ pages, slow but finally load the pages.

Sorry for the bad reference, I'll try to check this first

mikeytown2’s picture

Title: Problems with FastCGI & stream_select() » Debugging in the status report needs to be more detailed.
Project: Advanced CSS/JS Aggregation » HTTP Parallel Request & Threading Library
Version: 6.x-1.6 » 6.x-1.x-dev
Category: bug » feature
Status: Active » Needs review
StatusFileSize
new8.26 KB

I've attached a patch that adds in better debugging for httprl on the status page.

mikeytown2’s picture

Status: Needs review » Fixed

Above patch has been committed to HTTPRL. This is not an issue with AdvAgg; HTTPRL has been improved to help with the diagnosis of HTTP request errors.

RAFA3L’s picture

I notice one thing...

Installing a new and fresh Drupal site under Fastcgi and adding this to settings.php

$conf['drupal_http_request_fails'] = FALSE;

and enabling only Advagg I was happy because the page loads fast, even the admin/* pages

But the css styles don't load, the files folder was chmod 770. The folder advagg_css and optimized files were created but don't load.

When I change the permissions of the folder files/* to 777 the problem came back, turn all the site slow

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.