vonage-ruby-sdk icon indicating copy to clipboard operation
vonage-ruby-sdk copied to clipboard

http proxy support is broken in 7.21+

Open profforg opened this issue 1 year ago • 3 comments

After switching HTTP adapter from Net::HTTP to Net::HTTP::Persistent proxy support is broken:

WARN: TypeError: Parameter 'http': Expected type Net::HTTP, got type Net::HTTP::Persistent with hash 2926599207967444236
Caller: /opt/vendor/bundle/ruby/3.3.0/gems/vonage-7.26.0/lib/vonage/namespace.rb:18
Definition: /opt/vendor/bundle/ruby/3.3.0/gems/vonage-7.26.0/lib/vonage/http.rb:25 (Vonage::HTTP::Options#set)

profforg avatar Oct 16 '24 17:10 profforg

Hi @profforg can you provide some more detail about this issue? E.g. the specific steps which led to the error? Thanks!

superchilled avatar Oct 17 '24 10:10 superchilled

The http proxy credentials are passed when the client instance is initialized (since the system proxy settings from ENV are ignored) and when I try to send SMS I get this error

example code:

    client = Vonage::Client.new(
      http: {
        proxy_address: ENV.fetch('VONAGE_PROXY_ADDR', nil),
        proxy_port: ENV.fetch('VONAGE_PROXY_PORT', nil) },
      api_key: ENV.fetch('VONAGE_API_KEY', nil),
      api_secret: ENV.fetch('VONAGE_API_SECRET', nil)
    )
    client.sms.send(from:, to: phone:, text:, type:, callback:)

profforg avatar Oct 17 '24 18:10 profforg

@profforg I think I've identified the cause of the issue (actually, there are two separate, but related, underlying issues). I just need to investigate/test a bit more before pushing a fix. I'm aiming to release an update with a fix for this issue early next week.

superchilled avatar Oct 18 '24 15:10 superchilled

@profforg setting HTTP options is fixed in this release.

Note: some of the available options on Net::HTTP::Persistent are different from the ones on Net::HTTP (event though Net::HTTP::Persistent uses Net:HTTP under the hood). For example, there is a single setter for proxy rather than separate setters for proxy_address and proxy_port. See Rubydoc for more info.

superchilled avatar Oct 23 '24 09:10 superchilled