Ruby request to https - in `read_nonblock': Connection reset by peer (Errno::ECONNRESET)
There are several oddities in your code. The main is: since you use SSL
you are to aknowledge HTTP.start
about with :use_ssl => url.scheme == 'https'
. HTTP.Get
constructor awaits for an URI
, not the path. The summing up:
domain = 'http://www.google.com'
url = URI.parse("https://graph.facebook.com/fql?q=SELECT%20url,normalized_url%20FROM%20link_stat%20WHERE%20url='#{domain}'")
req = Net::HTTP::Get.new url
res = Net::HTTP.start(url.host, url.port,
:use_ssl => url.scheme == 'https') {|http| http.request req}
puts res
Gives:
#<Net::HTTPOK:0x000000027d0558>
Shopify Theme Ruby Gem Errors
This was an issue with the way ruby was installed on my Mac. After installing a new hard drive I installed RVM and Homebrew and everything worked fine.
Error while using Net::HTTP GET request
I believe the issue here is you're using an HTTP library to access an HTTPS service. These are fundamentally different things. Here's an HTTPS example:
require 'net/http'
require 'net/https'
http = Net::HTTP.new('www.example.com', 443)
http.use_ssl = true
http.ssl_version = :TLSv1
http.ciphers = "ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:-LOW"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
req = Net::HTTP::Get.new('/', {'Content-Type' =>'application/json'})
http.start {|http| http.request(req) }
Related Topics
Creating an Md5 Hash of a Number, String, Array, or Hash in Ruby
How to Generate the First N Prime Numbers
Rails 4 Migration: Has_And_Belongs_To_Many Table Name
Bundle Command Not Found in Linux Debian
Mapping Values from Two Array in Ruby
Sending a Post Request with Net/Http
Ruby Unable to Parse a CSV File: CSV::Malformedcsverror (Illegal Quoting in Line 1.)
How to Do Basic Authentication Over Https in Ruby
Cucumber, Capybara and Selenium - Submitting a Form Without a Button
Regex with Named Capture Groups Getting All Matches in Ruby
Rubymine: Rails Server Launcher Wasn't Found in the Project
What Is Double Method in Rspec For
How to Validate the Date Such That It Is After Today in Rails
Ruby: How to Count the Number of Times a String Appears in Another String