[WP 3.5.1] WordPress error code: http_request_failed – name lookup timed out
-
Hi there,
i installed today this plug-in in my blog, set up the settings but when i use the shortcode [rotatingtweets screen_name=’xxx’] using the correct user name instead of xxx i get this error (rotating in three frames):
Problem retrieving data from Twitter
Wordpress error code: http_request_failed – name lookup timed out
Please check your PHP and server settings.Any idea why?
Thanks!
-
This means that the set-up you are testing your site on (Linux/Apache/MySQL/PHP/Wordpress) isn’t connecting to the internet properly when WordPress asks it to.
I’m not sure why that would be the case, but it’s a server/Wordpress problem, not a Rotating Tweets problem.
Rotating Tweets doesn’t connect directly, but uses the WordPress connection to the net.
Do you have the latest version of WordPress?
There is some discussion of potential solutions here.
The HTTP module on the Core Control plug-in may also help.
As a quick PS, are you able to download plug-ins and updates directly into WordPress?
Hi, yes i can download, upload and update plug-ins directly from the plug-in section.
WP is 3.5.1 and Core Control tells me:
Manage Transports
Transport Status
cURL Available
PHP Streams Available
PHP fsockopen() AvailableHTTP Related Constants
WP_HTTP_BLOCK_EXTERNAL Undefined
WP_ACCESSIBLE_HOSTS Undefined
WP_PROXY_HOST Undefined
WP_PROXY_PORT Undefined
WP_PROXY_USERNAME Undefined
WP_PROXY_PASSWORD Undefined
WP_PROXY_BYPASS_HOSTS UndefinedHTTP Related Filters
http_request_timeout 5
http_request_redirection_count 5
http_request_version ‘1.0’
http_headers_useragent ‘WordPress/3.5.1; http://www.etcetc’
block_local_requests false
use_fsockopen_transport true
use_streams_transport true
use_curl_transport true
https_local_ssl_verify true
https_ssl_verify trueYou see something strange?
If it can helps, i’ve 2 other plug-in active, one for facebook and one for Pinterest, both working correctly.
Thank you so much for your help!Ok i don’t know if it was the right thing to do but i disabled cURL and now everything seems to work correctly (and the plug-in is great!).
Thanks a lotCool! That’s potentially useful to know for other people too.
Thank you!
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.
That would be appreciated.
Martin
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] => http://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] => http://www.google.com/after changing the nameserver the debugging info looked as follows
Array ( [url] => http://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] => http://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.
That’s helpful, although perhaps it suggests one fix could be to increase the timeout in line 26 of
lib/wp_twitteroauth.phpfrompublic $timeout = 3;to
public $timeout = 5.5;?!
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.
Hmmm. That could be a good idea and quite easy to do as well.
I’ll see if there’s an API-able way to switch off cURL as well…
Martin
I have tried the information given in this thread and am still having issues getting this twitter widget to work.
My site located at http://www.eriktv365.com
I’ve updated the development version of the plug-in to let you customise the timeout for the connection from your website to Twitter on the settings page.
Does it solve the problem if you increase it to 7 seconds?
I used the dev version, and still receive the same error after setting the 7 seconds.
Any other ideas?
Have any of the solutions at http://wordpress.org/support/topic/plugins-update-failure?replies=5#post-947582 helped?
Using the Core Control plug-in to investigate the problem and (usually) disable cURL has worked for some people.
The topic ‘[WP 3.5.1] WordPress error code: http_request_failed – name lookup timed out’ is closed to new replies.