Okay
  Public Ticket #3666032
table crash
Closed

Comments

  • Matthieu started the conversation

    Hello, 

    I face an issue with your plugin (cause when I remove it, no issue anymore). It takes several minutes to load my website pages (with table) and at the end I have "Erreur
    cURL error 28: Operation timed out after 100001 milliseconds with 0 bytes received" instead of the table...

    Can you help me please ?

    Thanks

    Matt

  •  1,767
    Miloš replied

    Hello Matt,

    There is a solution for this issue. Here are the instructions :

    1. If you're using the API method:

    This error is returned by the function wp_remote_get which uses cURL in the background. The client's server doesn't have time to manage the data from Google's API in 5 seconds (which is the default setting in WordPress).

    That limit can be increased using a hook https://wordpress.stackexchange.com/questions/341357/wp-remote-get-curl-error-28-only-on-same-domain.

     Instead of "15" set it to "100", just in case.

    If you get this error because of the WordPress hook extend_http_request_timeout, you need to remove it from your functions.php file and then check out solutions for the first initial error for curl error 28 - Operation timed out ...

    https://www.wpbeginner.com/wp-tutorials/how-to-fix-curl-error-28-connection-timed-out-after-x-milliseconds/


    2. If you're using the standard Google Sheet linked method (without Google's API credentials) the timeout limit is set to 25 in file wp-content/plugins/wpdatatables/source/class.wdttools.php on line 198.

    This can be overwritten with the hook wpdatatables_curl_get_data. For example:

    function filterCURLOptions($data, $ch, $url){
       $new_ch = curl_init();
       $timeout = 1000;
       $agent = 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0';
            curl_setopt($new_ch, CURLOPT_URL, $url);
            curl_setopt($new_ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($new_ch, CURLOPT_CONNECTTIMEOUT, $timeout);
            curl_setopt($new_ch, CURLOPT_USERAGENT, $agent);
            curl_setopt($new_ch, CURLOPT_REFERER, site_url());
            curl_setopt($new_ch, CURLOPT_FOLLOWLOCATION, true);
            $data = curl_exec($new_ch);
                if (curl_error($new_ch)) {
                    $error = curl_error($new_ch);
                    curl_close($new_ch);
                    throw new Exception($error);
                }
                if (strpos($data, '<title>Moved Temporarily</title>')) {
                    throw new Exception(__('wpDataTables was unable to read your Google Spreadsheet, probably it is not published correctly. <br> You can publish it by going to <b>File -> Publish to the web</b> ', 'wpdatatables'));
                }
                $info = curl_getinfo($new_ch);
                curl_close($new_ch);
                if ($info['http_code'] === 404) {
                    return NULL;
                }
       
        return $data;
    }
    add_filter('wpdatatables_curl_get_data','filterCURLOptions', 10, 3);
    

    This needs to go to the functions.php file of your theme or the child theme (depending on what you're using).

    Let us know how it goes.

    Thank you.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables