Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4634

Net::OpenTimeout (Seahorse::Client::NetworkingError) using aws-sdk-ec2

$
0
0

I have an EC2 instance in which I am running two scripts one ruby and another python to create another EC2 instance using aws-sdk for respective languages. Boto3 for python and aws-sdk-ec2 for ruby in this case.

Python env

Python Version: 3.8Boto3 version: 1.34.48

Python Script

import boto3ec2 = boto3.resource('ec2', region_name='ap-southeast-2')instance = ec2.create_instances(    ImageId='ami-0c41a31b32ca4785d',    MinCount=1,    MaxCount=1,    InstanceType='t2.micro',    SubnetId='subnet-07330e3514589cb2c1')print("Instance ID:", instance[0].id)

Output

i-064e9c7f6821df1d2

Ruby Env

Ruby Version: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]aws-sdk-ec2 version: 1.438.0

Ruby Script

require 'aws-sdk-ec2'require 'logger'logger = Logger.new(STDOUT)ec2 = Aws::EC2::Resource.new(region: 'ap-southeast-2',log_level: :debug, # Set log level to :debug  logger: logger )instance = ec2.create_instances({  image_id: 'ami-0c41a31b32ca4785d',  min_count: 1,  max_count: 1,  instance_type: 't2.micro',  subnet_id: 'subnet-07330e3514589cb2c1'})puts instance.first.id

Output

/usr/share/ruby3.2/net/protocol.rb:43:in `ssl_socket_connect': Net::OpenTimeout (Seahorse::Client::NetworkingError)        from /usr/share/ruby3.2/net/http.rb:1342:in `connect'        from /usr/share/ruby3.2/net/http.rb:1248:in `do_start'        from /usr/share/ruby3.2/net/http.rb:1243:in `start'        from /usr/share/ruby3.2/delegate.rb:87:in `method_missing'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/seahorse/client/net_http/connection_pool.rb:307:in `start_session'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/seahorse/client/net_http/connection_pool.rb:100:in `session_for'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/seahorse/client/net_http/handler.rb:128:in `session'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/seahorse/client/net_http/handler.rb:76:in `transmit'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/seahorse/client/net_http/handler.rb:50:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/seahorse/client/plugins/content_length.rb:24:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/seahorse/client/plugins/request_callback.rb:118:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/xml/error_handler.rb:10:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/sign.rb:54:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/transfer_encoding.rb:26:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/helpful_socket_errors.rb:12:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/retry_errors.rb:362:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/retry_errors.rb:396:in `retry_request'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/retry_errors.rb:384:in `retry_if_possible'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/retry_errors.rb:373:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/retry_errors.rb:396:in `retry_request'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/retry_errors.rb:384:in `retry_if_possible'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/retry_errors.rb:373:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/retry_errors.rb:396:in `retry_request'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/retry_errors.rb:384:in `retry_if_possible'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/retry_errors.rb:373:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/user_agent.rb:37:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/http_checksum.rb:20:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/endpoint_pattern.rb:30:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/checksum_algorithm.rb:137:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/request_compression.rb:94:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/query/handler.rb:30:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/recursion_detection.rb:18:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-ec2-1.438.0/lib/aws-sdk-ec2/plugins/endpoints.rb:43:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/endpoint_discovery.rb:84:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/seahorse/client/plugins/endpoint.rb:47:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/param_validator.rb:26:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/logging.rb:43:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/seahorse/client/plugins/raise_response_errors.rb:16:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/checksum_algorithm.rb:111:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/jsonvalue_converter.rb:16:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/idempotency_token.rb:19:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/param_converter.rb:26:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/seahorse/client/plugins/request_callback.rb:89:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/response_paging.rb:12:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/seahorse/client/plugins/response_target.rb:24:in `call'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/seahorse/client/request.rb:72:in `send_request'        from /usr/share/ruby3.2-gems/gems/aws-sdk-ec2-1.438.0/lib/aws-sdk-ec2/client.rb:56295:in `run_instances'        from /usr/share/ruby3.2-gems/gems/aws-sdk-ec2-1.438.0/lib/aws-sdk-ec2/resource.rb:636:in `block in create_instances'        from /usr/share/ruby3.2-gems/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/user_agent.rb:28:in `feature'        from /usr/share/ruby3.2-gems/gems/aws-sdk-ec2-1.438.0/lib/aws-sdk-ec2/resource.rb:635:in `create_instances'        from create_ec2.rb:9:in `<main>'

Considering the fact that both these scripts are running in the same ec2 instance I am unable to understand why ruby is failing to create an ec2 instance.

What else should I check in case of ruby?

Update 1

tcpdump for python.enter image description here

tcpdump for rubyenter image description here

As you can see I get a Server Hello right after ACK in case of python while I don't receive Server Hello in case of ruby

Update 2

Looks like the issue is with instances using AL2023. It works fine when using AL2.Also it does not work inside a docker container using the image ruby:3.0 on either of the operating systems.


Viewing all articles
Browse latest Browse all 4634

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>