Facing RestClient::Exceptions::OpenTimeout (Timed out connecting to server)
anew-bhav opened this issue · comments
Issue
Facing RestClient::Exceptions::OpenTimeout(Timed out connecting to server)
The endpoint is accessible if accessed from curl on the terminal and not from
Environment
rest-client v2.0.2
Ruby v2.5.0
macOs Mojave 10.14.6
Reproduction steps
url = 'https://npiregistry.cms.hhs.gov/api/?version=2.1&first_name=John&last_name=smith'
response = RestClient.get(url) #exception is raised after sometime
Extra Information
For other folks in my team, they are able to use this without facing the timeout. Also we have our rails application running on heroku, which also has no problem with this code. It is issue with my particular system.
url = 'https://www.google.com'
response = RestClient.get(url) #no exception is raised on the system
Efforts put in to investigate
I used byebug
to stop the code execution at several places in the gem codebase.
Consequently, I reached to the code where this exception would get raised.
This is inside the Net::Http in the connect method.
You can have a look here
I tried uninstalling ruby and all the gem and reinstalling them
But the issue didn't go.
I am out of options to debug this further. Any help would be appreciated.
I had a similar issue which turned out to be a problem with DNS resolution. Fixed with:
require 'resolv-replace'
@cwisdo Thanks for the help.
adding resolv-replace
helped
Where do you guys add resolv-replace