WordPress.org

Ready to get started?Download WordPress

Forums

Rotating Tweets (Twitter widget and shortcode)
[resolved] [WP 3.5.1] WordPress error code: http_request_failed - name lookup timed out (29 posts)

  1. darkiko
    Member
    Posted 11 months ago #

    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!

    http://wordpress.org/extend/plugins/rotatingtweets/

  2. Martin Tod
    Member
    Plugin Author

    Posted 11 months ago #

    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.

  3. Martin Tod
    Member
    Plugin Author

    Posted 11 months ago #

    As a quick PS, are you able to download plug-ins and updates directly into WordPress?

  4. darkiko
    Member
    Posted 11 months ago #

    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() Available

    HTTP 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 Undefined

    HTTP 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 true

    You 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!

  5. darkiko
    Member
    Posted 11 months ago #

    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 lot

  6. Martin Tod
    Member
    Plugin Author

    Posted 11 months ago #

    Cool! That's potentially useful to know for other people too.

    Thank you!

  7. Jeremy Quinton
    Member
    Posted 10 months ago #

    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.

  8. Martin Tod
    Member
    Plugin Author

    Posted 10 months ago #

    That would be appreciated.

    Martin

  9. Jeremy Quinton
    Member
    Posted 9 months ago #

    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.

  10. Martin Tod
    Member
    Plugin Author

    Posted 9 months ago #

    That's helpful, although perhaps it suggests one fix could be to increase the timeout in line 26 of lib/wp_twitteroauth.php from

    public $timeout = 3;

    to

    public $timeout = 5.5;

    ?!

  11. Jeremy Quinton
    Member
    Posted 9 months ago #

    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.

  12. Martin Tod
    Member
    Plugin Author

    Posted 9 months ago #

    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

  13. eriktv365
    Member
    Posted 8 months ago #

    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

  14. Martin Tod
    Member
    Plugin Author

    Posted 8 months ago #

    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?

  15. eriktv365
    Member
    Posted 8 months ago #

    I used the dev version, and still receive the same error after setting the 7 seconds.

    Any other ideas?

  16. Martin Tod
    Member
    Plugin Author

    Posted 8 months ago #

    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.

  17. eriktv365
    Member
    Posted 8 months ago #

    I have tried the disable cURL which provides a different error but still does not fix the connection.

  18. Martin Tod
    Member
    Plugin Author

    Posted 8 months ago #

    What debug information does Core Control give you?

    Is there anything on /wp-admin/tools.php?page=core-control&module=http that gives any clues?

    Best wishes,

    Martin

  19. eriktv365
    Member
    Posted 8 months ago #

    Method GET
    Result error
    Error Details
    http_request_failed connect() timed out!
    Time Taken 7.0042169094086 seconds
    HTTP Args
    timeout (integer) 7
    redirection (integer) 5
    httpversion (string) 1.0
    user-agent (string) WordPress/3.6; http://eriktv365.com
    reject_unsafe_urls (boolean) false
    blocking (boolean) true
    headers
    Array
    (
    )
    cookies
    Array
    (
    )
    compress (boolean) false
    decompress (boolean) true
    sslverify (boolean) false
    stream (boolean) false
    filename NULL
    limit_response_size NULL
    HTTP Transports WP_HTTP_curl
    Request Time 2013-08-11 12:19:50 --500

  20. Martin Tod
    Member
    Plugin Author

    Posted 8 months ago #

    I've updated the development version to give you an option of 20 seconds!

    I've now found some useful information that might let me block cURL via Rotating Tweets as well (although, as you say, this doesn't seem to solve the problem).

    Martin

  21. eriktv365
    Member
    Posted 8 months ago #

    I downloaded the new dev version and set the timeout to 20 seconds, but then when I set the save option at the bottom I still get this message at the top of the Rotating Tweets settings page in return:

    Error message received from Twitter: couldn't connect to host. Please check your API key, secret, token and secret token on the Twitter website.

    I have checked double checked and rebuilt the keys with no luck...

  22. Martin Tod
    Member
    Plugin Author

    Posted 8 months ago #

    I need to sort out that error message (and have done so on the latest development version)!

    I doubt it is anything to do with Rotating Tweets - and changing the keys probably isn't going to help. Rotating Tweets is using the 'bog-standard' HTTP API that is built into WordPress.

    The problem is the connection between your host (via the server) and other sites. Do any of the HTTP transports work in the core control plug-in?

  23. eriktv365
    Member
    Posted 8 months ago #

    What can I do to test them? My host is GoDaddy by the way.

  24. Martin Tod
    Member
    Plugin Author

    Posted 8 months ago #

    Do the testing links on /wp-admin/tools.php?page=core-control&module=http work?

  25. eriktv365
    Member
    Posted 8 months ago #

    yeah they all return successfully.

  26. ngocdoangia
    Member
    Posted 8 months ago #

    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.
    su kien

  27. Martin Tod
    Member
    Plugin Author

    Posted 8 months ago #

    While I remember, have you tried the switching the "Verify SSL connection to Twitter" to "No" in the Rotating Tweets settings?

    Apart from that I can only suggest switching all the transports off and then switching them on one at a time to see if one of them works.

  28. eriktv365
    Member
    Posted 8 months ago #

    I tried all of that... sad that I can't get this wonderful plugin to work.

  29. Martin Tod
    Member
    Plugin Author

    Posted 8 months ago #

    I can only think it's a problem with your hosting or your server. I don't really have any other ideas to suggest.

    Are you able to install plug-ins and upgrades via the WordPress Admin pages? Or do you have to upload them separately?

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.