Created
May 27, 2014 08:28
-
-
Save SaschaMoellering/fa42e263d754c0b728ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
link = URI.parse('http://169.254.169.254/latest/meta-data/instance-id') | |
request = Net::HTTP::Get.new(link.path) | |
begin | |
response = Net::HTTP.start(link.host, link.port) { |http| | |
http.read_timeout = 5 #Default is 60 seconds | |
http.request(request) | |
} | |
rescue Exception => e | |
puts e.message | |
puts e.class | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
▶ ruby timeout.rb | |
Operation timed out - connect(2) | |
Errno::ETIMEDOUT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment