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

Getting Twitter::Error::ClientError: execution expired #401

Closed
csph8 opened this Issue May 28, 2013 · 26 comments

Comments

Projects
None yet
@csph8

csph8 commented May 28, 2013

Getting this error Twitter::Error::ClientError: execution expired often & often

@stve

This comment has been minimized.

Collaborator

stve commented May 29, 2013

Sounds like your requests might be timing out. Perhaps try adjusting the request timeout settings in your connection options to see if that makes a difference?

Twitter.configure do |config|
  config.connection_options = Twitter::Default::CONNECTION_OPTIONS.merge(:request => { 
    :open_timeout => 5,
    :timeout => 10
  })
end

What's above are the default values, you'll need to adjust them as you see fit.

@sferik

This comment has been minimized.

Owner

sferik commented Jul 24, 2013

This is an issue with the Twitter API, not this library.

@ys

This comment has been minimized.

Contributor

ys commented Jul 24, 2013

Is everyone getting that on heroku or also elsewhere?
It seems to work fine locally:(

@jalada

This comment has been minimized.

Contributor

jalada commented Jul 25, 2013

👍 Also been getting this quite a lot...wondering if it's something to do with Heroku?

@lyuzashi

This comment has been minimized.

lyuzashi commented Jul 26, 2013

I've deployed some code to Heroku in the last hour using the Twitter Gem. It worked perfectly in development, responding within under a second. Could not get a response in production, just as described here.

@jalada

This comment has been minimized.

Contributor

jalada commented Jul 26, 2013

Still getting this. The Twitter API status page says nothing and identical code performs just fine in development. It might not be an issue with this library, but what is it an issue with? What are the rules that would cause the Twitter API to simply not respond?

@jeremyhaile

This comment has been minimized.

jeremyhaile commented Jul 26, 2013

I'm getting this a ton. And I'm on Heroku as well.I don't think the problem is with the Twitter gem, but Twitter's API status page says everything is ok, but I'm getting this error MANY times a day. Anyone have ideas or workarounds?

@jalada

This comment has been minimized.

Contributor

jalada commented Jul 26, 2013

@jeremyhaile Try using the Proximo add-on to proxy your requests via a static IP. I switched to this a few hours ago and haven't had the problem since, but that might just be luck.

I configured the Twitter gem to use Proximo like this:

Twitter.configure do |config|
  if ENV["PROXIMO_URL"]
  config.connection_options = Twitter::Default::CONNECTION_OPTIONS.merge(proxy: {
    uri: ENV["PROXIMO_URL"]
  })
end

I configured Omniauth (because I was using oAuth too, and that also had timeouts) like this:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET'], {client_options: {
    :proxy => ENV["PROXIMO_URL"] } }
end

Good luck.

The fact I was having Omniauth problems shows it isn't the gem specifically. Unfortunately.

@jeremyhaile

This comment has been minimized.

jeremyhaile commented Jul 26, 2013

@jalada any idea why you'd need to switch to Proximo? That would be a pretty expensive add-on for us. I'd much rather find a solution that doesn't require paying hundreds of dollars a month.

@ys

This comment has been minimized.

Contributor

ys commented Jul 26, 2013

For me the problem is really coming from EC2 heroku instances with certains IPs that might be limited or blacklisted by twitter.

@jeremyhaile

This comment has been minimized.

jeremyhaile commented Jul 26, 2013

By the way, given that this does not appear to be an actual Twitter gem issue, I've opened a stackoverflow question with tags heroku and twitter here: http://stackoverflow.com/questions/17883444/receiving-execution-expired-errors-on-twitter-from-heroku

@jeremyhaile

This comment has been minimized.

jeremyhaile commented Jul 26, 2013

@ys How do you know the IPs are limited or blacklisted?

@jalada

This comment has been minimized.

Contributor

jalada commented Jul 26, 2013

@jeremyhaile What @ys said. I'm hypothesising here, but I think Twitter have changed their blacklist rules and are now flatly ignoring requests from blacklisted IP addresses, and some of those are unfortunately Heroku IP addresses on EC2. This is the problem with IP-based blocking in the world of the cloud.

If Proximo is expensive for you, run your own proxy on a server somewhere else, and proxy your requests through that.

When I am certain using a proxy solves the issue I will be raising a bug with Twitter.

@ys

This comment has been minimized.

Contributor

ys commented Jul 26, 2013

@jeremyhaile it's like @jalada said exactly.

And I don't know it I just suppose

@jeremyhaile

This comment has been minimized.

jeremyhaile commented Jul 26, 2013

@jalada ok thanks for the info. I've also reached out to Heroku about this and referred to these bug comments and the stack overflow question.

@abyx

This comment has been minimized.

abyx commented Jul 26, 2013

Having the same errors with this gem on heroku

@ys

This comment has been minimized.

Contributor

ys commented Jul 26, 2013

Support from heroku said they were looking internally and with twitter engineers…

On 26 Jul 2013, at 18:23, Aviv Ben-Yosef notifications@github.com wrote:

Having the same errors with this gem on heroku


Reply to this email directly or view it on GitHub.

@jeremyhaile

This comment has been minimized.

jeremyhaile commented Jul 26, 2013

Awesome - thanks for the update!

On Friday, July 26, 2013 at 12:57 PM, Yannick Schutz wrote:

Support from heroku said they were looking internally and with twitter engineers…

On 26 Jul 2013, at 18:23, Aviv Ben-Yosef <notifications@github.com (mailto:notifications@github.com)> wrote:

Having the same errors with this gem on heroku


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub (#401 (comment)).

@mkumarrails

This comment has been minimized.

mkumarrails commented Jul 29, 2013

getting the same issue "Twitter::Error::ClientError: execution expired: frequently.

@karthikselva

This comment has been minimized.

karthikselva commented Jul 29, 2013

1.9.3-p448 :018 > Twitter.update("I'm tweeting with @gem!")
Twitter::Error::ClientError: execution expired

It never succeds.

@jeremyhaile

This comment has been minimized.

jeremyhaile commented Jul 29, 2013

If you are having problems with this, please file a ticket with Heroku and and comment on this Twitter discussion: https://dev.twitter.com/discussions/20185

@bcackerman

This comment has been minimized.

bcackerman commented Dec 14, 2013

Make sure you guys rescue with

Twitter::Error, Timeout::Error => e
@jacqueline-homan

This comment has been minimized.

jacqueline-homan commented Jan 5, 2014

I don't think this is a heroku issue. I am building an app right now that uses the Twitter gem that is NOT being deployed on heroku and I have the same exact problem in the test and development stage:

Twitter::Error::ClientError: execution expired:

sferik added a commit that referenced this issue Jan 22, 2014

Add Twitter::Error::RequestTimeout
This is a new class to catch timeout errors, such that they may be
retried.

It may be used as follows:

begin
  # Make a request using a Twitter::REST::Client
rescue Twitter::Error::RequestTimeout
  retry
end

Prior to this patch, to get the same behavior, you'd need to do this:

begin
  # Make a request using a Twitter::REST::Client
rescue Timeout::Error, Twitter::Error => error
  if error.is_a?(Timeout::Error) || error.cause.is_a?(Timeout::Error) || error.cause.is_a?(Faraday::Error::TimeoutError)
    retry
  else
    raise
  end
end

See #401.
@nozpheratu

This comment has been minimized.

nozpheratu commented Mar 6, 2015

I'm running into this issue seemingly only on my development host. My Twitter client is connecting just fine on my production servers, I connect with the exact same keys in production as I do in development.

Could twitter be blacklisting my IP? I handle the error, but it gets slightly annoying waiting for the Twitter client to time out every time I try to connect in development. Seems like the ability to specify a custom expiration time has been deprecated.

@stve

This comment has been minimized.

Collaborator

stve commented Mar 6, 2015

@nozpheratu are you streaming or are these REST requests? If you are streaming, the following applies:

A client establishes too many connections with the same credentials. When this occurs, the oldest connection will be terminated. This means you have to be careful not to run two reconnecting clients in parallel with the same credentials, or else they will take turns disconnecting each other.

Either way, I'd recommend using environment specific credentials.

@nozpheratu

This comment has been minimized.

nozpheratu commented Mar 6, 2015

@stve These are REST requests. I'm trying to access user_timeline when the timeout occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment