httprb / http

HTTP (The Gem! a.k.a. http.rb) - a fast Ruby HTTP client with a chainable API, streaming support, and timeouts
MIT License
3.01k stars 321 forks source link

Problem with httprb and SSL::VERIFY_NONE Mode #607

Open rkhapre opened 4 years ago

rkhapre commented 4 years ago

Hi All

I am using the httprb, its working well with https many URL. But one of the URL uses the SSL certificate, so i have used Verify as None like below

ctx = OpenSSL::SSL::SSLContext.new
ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE

Out of 10 request, 8 times i get below response/Error but for other 2 request when i get i get the perfect response

/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.2.0/lib/http/timeout/global.rb:36:in ``connect_nonblock': read would block (OpenSSL::SSL::SSLErrorWaitReadable)

` To me looks like this issue with combination of httprb and Open SSL. Where i can set the SSL Wait Read timeout ? I do not see any option

I checked many users have used this option "OpenSSL::SSL::VERIFY_NONE", so they also might be experiencing same issue. So we have any solution for this?

Thanks.

ixti commented 4 years ago

Please, check out https://github.com/httprb/http/wiki/Timeouts We have a bit too strict default values #579 right now, which we will bump up in next major release

rkhapre commented 4 years ago

@ixti . Thanks for your reply. I have checked this earlier as well. I was using global timeout of 50. Then also had similar issue. Now i used this HTTP.timeout(connect: 50, write: 2, read: 50). Even though i keeping read as 50, i have similar issue. Out of 10 times, 8 times i get this response

I switched to latest version 4.4.1, then also same. If i use HTTP.persistent then the code runs forever


C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/timeout/null.rb:63:in `rescue in rescue_readable': Read timed out after 50 seconds (HTTP::TimeoutError)
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/timeout/null.rb:59:in `rescue_readable'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/timeout/per_operation.rb:30:in `connect_ssl'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/timeout/null.rb:36:in `start_tls'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/connection.rb:158:in `start_tls'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/connection.rb:46:in `initialize'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/client.rb:71:in `new'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/client.rb:71:in `perform'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/client.rb:31:in `request'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/chainable.rb:20:in `get'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/timeout/per_operation.rb:32:in `connect_nonblock': read would block (OpenSSL::SSL::SSLErrorWaitReadable)
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/timeout/per_operation.rb:32:in `block (2 levels) in connect_ssl'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/timeout/null.rb:68:in `rescue_writable'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/timeout/per_operation.rb:31:in `block in connect_ssl'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/timeout/null.rb:60:in `rescue_readable'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/timeout/per_operation.rb:30:in `connect_ssl'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/timeout/null.rb:36:in `start_tls'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/connection.rb:158:in `start_tls'

``` from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/connection.rb:46:in `initialize'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/client.rb:71:in `new'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/client.rb:71:in `perform'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/client.rb:31:in `request'
    from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/http-4.4.1/lib/http/chainable.rb:20:in `get'