Jeremy Quinton
Forum Replies Created
-
That would be a better solution for sure. I have been doing PHP for 10 years but have only been working with Word Press a couple weeks so probably should have taken a closer look at the plugin.
Maybe a setting for the plugin called http timeout would help which people could up if the needed to.
Anyways thanks for the plugin otherwise it works really well for me.
The short answer.
The plugin is using internal wordpress functions which rely on curl.
Have a look at the wp-includes/class-http.php file. The request function line 1043 and the underlying code the timeout is set to 5 seconds. Therefore when curl does a request and it takes longer than 5 seconds you will get this issue.A possible solution would be to override the wordpress defaults but Im not sure how to do that.
The long answer.
I did some debugging and was able to work out the following.
The problem on my development machine locally was that name-server lookups were taking forever. Im using centos 6.3 but generally Linux uses /etc/resolv.conf where nameservers can be specified. That was set to a nameserver that was slow in responding. The underlying bits of Curl use this name server lookup configuration.
I changed it to 8.8.8.8 which is googles dns servers and that solved the problem.
What you can do to debug curl locally is the following.
// create curl resource $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, "google.com"); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $output = curl_exec($ch); //get the info of the last request $info = curl_getinfo($ch); print_r($info); // close curl resource to free up system resources curl_close($ch);
For me the output looked like this before I changed the nameserver. namelookup_time is the culprit.
[url] => https://google.com [content_type] => text/html; charset=UTF-8 [http_code] => 301 [header_size] => 321 [request_size] => 49 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 5.102859 [namelookup_time] => 5.0526 [connect_time] => 5.071828 [pretransfer_time] => 5.071922 [size_upload] => 0 [size_download] => 219 [speed_download] => 42 [speed_upload] => 0 [download_content_length] => 219 [upload_content_length] => 0 [starttransfer_time] => 5.102791 [redirect_time] => 0 [certinfo] => Array ( ) [primary_ip] => 173.194.34.66 [redirect_url] => https://www.google.com/
after changing the nameserver the debugging info looked as follows
Array ( [url] => https://google.com [content_type] => text/html; charset=UTF-8 [http_code] => 301 [header_size] => 321 [request_size] => 49 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.079125 [namelookup_time] => 0.02969 [connect_time] => 0.049101 [pretransfer_time] => 0.049123 [size_upload] => 0 [size_download] => 219 [speed_download] => 2767 [speed_upload] => 0 [download_content_length] => 219 [upload_content_length] => 0 [starttransfer_time] => 0.079049 [redirect_time] => 0 [certinfo] => Array ( ) [primary_ip] => 173.194.34.128 [redirect_url] => https://www.google.com/ )
Have a look at the difference in the two outputs between namelookup_time it is significantly reduced in the second output.
Hope this helps someone.
By disabling curl also got the plugin working for me.
This is rather odd.
I might do some further debugging and post the results here.