Open drqCode opened 8 months ago
@drqCode,
I threw together this simple script and it ran successfully inside of the ruby:3.3.0-slim-bookworm
container. I do not think that your issue is caused by a limitation of the ruby client library or Recurly API.
Script:
require 'recurly'
client = Recurly::Client.new(api_key: ENV['RECURLY_API_KEY'])
sites = client.list_sites
sites.each do |site|
puts "Site: #{site.mode}"
end
Execution:
└[$]›docker run -it --rm -e RECURLY_API_KEY=$RECURLY_API_KEY -v $(pwd):/app -w /app ruby:3.3.0-slim-bookworm bash -c "bundle && bundle exec ruby container-test.rb"
Fetching gem metadata from https://rubygems.org/.............
Fetching recurly 4.47.0
Installing recurly 4.47.0
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
/usr/local/bundle/gems/recurly-4.47.0/lib/recurly/client.rb:4: warning: base64 was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add base64 to your Gemfile or gemspec. Also contact author of recurly-4.47.0 to add base64 into its gemspec.
Site: sandbox
The error happens intermittently and not often. The behavior is very like this: https://github.com/redis/redis-rb/issues/1106. I will debug on this more, but so far everything points to this gem where it uses persistent HTTP connections, but it does not gracefully handle those SSL EOF while reading errors. Note that between bullseye and bookworm, OpenSSL is upraded from 1.1.1 to 3.0.9.
@douglasmiller we still experience that issue. The issue seems to be this: https://github.com/openssl/openssl/discussions/22690. I couldn't reproduce this via a script yet. It happens regularly on a clustered puma prod app, but we managed to overcome the error by patching the keep_alive_timeout in gem's connection pool:
module Recurly
class ConnectionPool
def init_http_connection(uri, ca_file)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == 'https'
http.ca_file = ca_file
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.keep_alive_timeout = 10 # lowering the timeout avoids the error
http
end
end
end
My assumption is that Recurly server does not close connections properly in certain conditions. By setting a lower keep alive the client will close connection before the server may get that chance.
@douglasmiller The issue still persists. Did you try to reproduce it? You should use a client instance and try to requests spanned over a couple of minutes.
Intermittent SSL Error is occurring when requesting Recurly service. Stack trace:
Note: Some trace lines were removed due to sec policies.
This started once we upgraded the base docker image from ruby:3.3.0-slim-bullseye to ruby:3.3.0-slim-bookworm.
Your Environment