Net :: HTTP extremely slow responses for HTTPS requests

For some reason, on my development machine, I get very slow responses to HTTPS requests made through Net :: HTTP. I tried RestClient and HTTParty, and they both have the same problem. It seems he came out of nowhere. I have done these queries hundreds of times without problems, but today they are unbearably slow.

pry(main)> puts Time.now; HTTParty.get('https://api.easypost.com/v2/addresses'); puts Time.now; 2015-04-29 08:07:08 -0500 2015-04-29 08:09:39 -0500 

As you can see, the answer took 2.5 minutes. And this is not just this EasyPost API URL. I have tried numerous SSL requests to servers that I know can connect to ( https://google.com , https://weather.com , etc.), and all of them lead to the same behavior. In addition, I noticed that the same thing happens for requests redirected from HTTP to HTTPS. Now check the non-ssl request:

 pry(main)> puts Time.now; HTTParty.get('http://lookitsatravis.com'); puts Time.now; 2015-04-29 08:12:22 -0500 2015-04-29 08:12:22 -0500 

Flowing. What gives? I assume this is some configuration problem somewhere between Ruby and OpenSSL. I have reinstalled both (using Ruby 2.2.1 and OpenSSL 1.0.2a) and I am using OS X Yosemite 10.10.2 for what it costs. Reinstalled all my gems, but the problem persists. I tried changing the DNS settings just in case, but not the cubes. Is there somewhere else I can look at or any configuration that I can change that will fix this problem?

+6
source share
2 answers

The problem is not Ruby, OpenSSL, or any of the above libraries. The problem is that IPv6 addresses were not resolved on my MacBook. The DNS lookup first returned the IPv6 address, so the libraries tried to connect to it until it was exhausted, and then they connected to the IPv4 addresses, which worked fine.

Disabling IPv6 for OS X Yosemite 10.10.2 worked for me. This is not ideal, but until I can determine another solution, it works.

 networksetup -setv6off "Wi-Fi" 

Thanks to @SteffenUllrich for pointing me in that direction.

+5
source

What solved the problem for me is to disable the antivirus

-2
source

Source: https://habr.com/ru/post/986225/


All Articles