Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection timed out - connect(2) #274

Closed
nodakjones opened this issue Jun 21, 2012 · 3 comments
Closed

Connection timed out - connect(2) #274

nodakjones opened this issue Jun 21, 2012 · 3 comments

Comments

@nodakjones
Copy link

It looks like Twitter is down right now and because I have this gem loaded on the front page of my site, then my site is down. Any thoughts about how to gracefully handle this type of an issue?

@DriesS
Copy link

DriesS commented Jun 21, 2012

+1 same here, website not accessible because downtime twitter!

@jamesmk
Copy link

jamesmk commented Jun 21, 2012

You can set a timeout exception, in Rails it would be:

require 'timeout'
begin
  @tweets = Timeout.timeout(5) do # try for 5 seconds
    Twitter.user_timeline('my_handle')
  end
rescue Timeout::Error
  logger.debug('oh noes')
end

@sferik
Copy link
Owner

sferik commented Jun 21, 2012

The twitter gem uses faraday to perform HTTP requests and already exposes an interface to pass arbitrary connection options to faraday. For example:

Twitter.connection_options = {:timeout => 5, :open_timeout => 2}

@sferik sferik closed this as completed Jun 21, 2012
sferik added a commit that referenced this issue Jun 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants