getting a connection reset by peer error when hitting Google Contacts API
You're requesting an HTTPS resource, so your GET request needs to use SSL encryption.
http://ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTP.html#method-i-use_ssl-3F
So your last line should look like:
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # You should use VERIFY_PEER in production
request = Net::HTTP::Get.new(uri.request_uri)
res = http.request(request)
Ruby HTTP Library gets Connection Reset with Facebook App
Thanks to Manoj Awasthi for making me realize that there were ssl methods that I couldn't use.
The problem was that I was requiring net/http rather than net/https.
Working snippet:
fb_access_token_url = URI.parse(
'https://graph.facebook.com/oauth/access_token' +
'?grant_type=client_credentials' +
'&client_id=' + FACEBOOK_APP_ID +
'&client_secret=' + FACEBOOK_APP_SECRET)
https = Net::HTTP.new(fb_access_token_url.host, fb_access_token_url.port)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
fb_access_token = https.request_get(fb_access_token_url.path + '?' +
fb_access_token_url.query)
A connection was successfully established with the server, but then an error occurred during the pre-login handshake
Solution
1) Clean your VS.Net Solution
2) Rebuild Project.
3) Reset IIS
4) Run the project again.
Basically that solved my problem, but in my case i was not getting this error and suddenly my local environment starts giving me above error, so may be that trick work for me.
Rails Google Oauth2 Working Locally But Not Remotely
It looks like you use GET
requests to /auth/:provider
endpoints.
There is security concern with it. You need to change the verb to POST
.
See https://stackoverflow.com/a/65785932/2131983 for more details.
Getting 500 Internal Server Error while trying to send an email using Mailgun in Heroku , using Rails 7 and mail_form
Thanks to the help of the comments, I was able to notice by the line in the heroku logs:
2022-04-28T20:35:32.116916+00:00 app[web.1]: [b1e694c5-cea3-427f-bbdd-aa3cc3a92d6b] Errno::ECONNREFUSED (Connection refused - connect(2) for 127.0.0.1:25):
The port being used was 25
instead of 587
meaning that the blockActionMailer::Base.smtp_settings = {
:port => ENV['MAILGUN_SMTP_PORT'],
:address => ENV['MAILGUN_SMTP_SERVER'],
:user_name => ENV['MAILGUN_SMTP_LOGIN'],
:password => ENV['MAILGUN_SMTP_PASSWORD'],
:domain => 'https://www.example.com/',
:authentication => :plain,
}
Was being ignored, by instead encompassing those option inside a config.action_mailer.smtp_settings
I was able to resolve the issue. What is my error log telling me?
Yes, it seems that the error is on their part.
Typhoeus -https://github.com/typhoeus/typhoeus
is the default user agent.
https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus.rb#L50
Related Topics
Modifying Text Inside HTML Nodes - Nokogiri
Why Are Global Methods Allowed to Be Defined Outside of a Class in Ruby
Belongs_To Presence in Rails 5 Not Working
Using Google Search Rest API in Ruby
Can't Install Debugger Gem - Rails - MAC Osx Mavericks
Algorithm to Render a Horizontal Binary-Ish Tree in Text/Ascii Form
Convert Durations in Ruby - Hh:Mm:Ss.Sss to Milliseconds and Vice Versa
Phusion Passenger with Ruby 1.8 and 1.9
Alias_Method on Activerecord::Base Results in Nameerror
Rails Has_Many Through Form with Additional Attributes
Ruby - Generate All Two Letter Words
Rake Cucumber and Rake Spec Always Use "Develop" Environment
Rails/Postgres, 'Foreign Keys' Stored in Array to Create 1-Many Association
How to Calculate a String's Width in Ruby
Get All Products of Category and Child Categories (Rails, Awesome_Nested_Set)