1

I'm trying to use the API of the Bureau of Labor Statistics, and trying to use the API using curl works perfectly and returns the results almost immediately:

curl -X GET "https://api.bls.gov/publicAPI/v2/timeseries/data/CFU0000008000"

However, when I try to run this in irb using rest-client, it always causes a RestClient::Exceptions::OpenTimeout (Timed out connecting to server) exception:

RestClient.get "https://api.bls.gov/publicAPI/v2/timeseries/data/CFU0000008000"

If I increase the open timeout, to say 240, it works and gets the results eventually but it takes forever. I tried uninstalling and installing rails again, but I haven't been able to figure out the issue.

I'm running rails 6.0.2.2, ruby 2.7, and rest-client 2.1.0 on macOS Catalina.

Update: on researching this further, I see that the RestClient::Exceptions::OpenTimeout exception wraps Net::OpenTimeout so this is something not specific to rest-client maybe.

1
  • Is ruby running in the same environment as curl? Same proxy settings, interface etc?
    – su_li
    Commented Apr 6, 2020 at 19:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.