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

Seahorse::Client::NetworkingError: execution expired when calling Aws::EC2::Instance#start #904

Closed
cmhobbs opened this issue Aug 19, 2015 · 4 comments
Labels
guidance Question that needs advice or information.

Comments

@cmhobbs
Copy link

cmhobbs commented Aug 19, 2015

I'm using v2.1.11 and I'm trying to create and/or interact with EC2 instances thusly:

credentials = Aws::Credentials.new('aws_access_key_id', 'aws_secret_access_key')
client      = Aws::EC2::Client.new(region: 'us-west-2a', credentials: credentials)
ec2         = Aws::EC2::Instance.new({ id: 'SampleID', client: client, instance_type: 'sample.type', image_id: 'sample-id' })

When I call ec2.start (or any other method that might reach out to AWS itself), I get the following error:

Seahorse::Client::NetworkingError: execution expired
from /home/christopher/.rbenv/versions/2.1.5/lib/ruby/2.1.0/net/http.rb:879:in `initialize'

After some searching, I thought this might be related to SSL issues (though the error doesn't state anything about that), so for kicks I tried the following options, each in isolation:

  • Aws.use_bundled_cert!
  • Aws.config[:ssl_verify_peer] = false

In the same console and in the same codebase, I'm able to create Kinesis, S3, and AutoScale services without any errors using a similar pattern.

Thanks for your time!

@trevorrowe
Copy link
Member

In your configuration, you gave the name of an availability zone where a region is expected. You should be able to simply replace "us-west-2a" with "us-west-2" and your code should work. The reason this gave you a networking error is because it was attempting to connect to ec2.us-west-2a.amazonaws.com which is not a valid domain.

Another note, it looks like you are trying to create an instance. Constructing an instance of the Aws::EC2::Instance class will only create a local reference to an instance by ID so that you can operate against it. For example, if I know the id of an instance I own, I can do the following to get status or to terminate it:

instance = Aws::EC2::Instance.new('i-12345678')
instance.state.name #=> "running"
instance.terminate

If you want to run a new instance you should use Aws::EC2::Resource#create_instances (http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Resource.html#create_instances-instance_method) or Aws::EC2::Client#run_isntances (http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#run_instances-instance_method):

ec2 = Aws::EC2::Resource.new(region: '...', access_key_id: '...', secret_access_key: '...')
instances = ec2.create_instances(instance_type: 'sample.type', image_id: 'sample-id', min_count: 2, max_count: 2)

Hope this helps!

@cmhobbs
Copy link
Author

cmhobbs commented Aug 19, 2015

I think you nailed it, thanks!

@sbwoodside
Copy link

+1 I just had this problem with AWS S3 upload in ruby, doing this:

s3 = Aws::S3::Resource.new
bucket = s3.bucket(ENV['S3_BUCKET'])
s3object = bucket.object('hello.png')
s3object.upload_file('/some/file')

I had AWS_REGION=us-east-1a in my .env file. Changed it to AWS_REGION=us-east-1 and it's fixed.

It would be nice if the error could be more informative.

@jose2007kj
Copy link

got this error when my network upload speed was low. got it working when i connected my system to other network with good speed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

5 participants