0

Context: I have a Cloudfoundry app running on Ruby 3.0. I'm using a forward proxy to access an external API and that proxy is going away soon so I have to switch to a new service. Problem: When I switch I receive a 404 error.

The new proxy admin says he doesn't see anything coming when I get the 404 error. When I use curl, I can access the URL through the new proxy and the admin can see it.

I was using Net::http on ruby 2.x, I upgraded to ruby 3.0 and moved to httpclient, then Faraday, same issue.

error: /home/vcap/deps/0/vendor_bundle/ruby/3.2.0/gems/net-http-0.6.0/lib/net/http/response.rb:277:in `error!': 404 "Not Found" (Faraday::ConnectionFailed)

Right now my tests consist of a simple GET on https://www.google.com because th eresult is the same, http 404.

    @proxi = {
      uri: "#{get_config.proxy.protocol}://#{get_config.proxy.hostname}:#{get_config.proxy.port}",
      user: "#{get_config.proxy.username}",
      password: "#{get_config.proxy.password}"
    }

    conn = Faraday.new(
      proxy: @proxi
    ) do |faraday|
      faraday.response :logger, ::Logger.new(STDOUT), { headers: true, bodies: true, errors: true }
      faraday.adapter Faraday.default_adapter
    end

    response = conn.get("https://www.google.com") do |req|
      req.headers['Content-Type'] = 'application/json'
    end

Proxy object is correct, and the values are taken from the environment where I run the app, the same parameters that work with curl. The only difference I see between the old and the new proxy is that the url is using https signed with an internal certificate. But if I had a handshake issue I guess I would have a different error?

I'm not sure where to get from there. Any idea?

2
  • 2
    Have you tried a stand-alone Ruby script with everything stripped to the bone, with one simple Faraday request and all settings hard coded into the script. In this isolated script, enable full Faraday debugging. What's the result? Commented Sep 23 at 5:51
  • "The only difference I see between the old and the new proxy is that the url is using https signed with an internal certificate. But if I had a handshake issue I guess I would have a different error?" We have no idea what uri you are proxying through but maybe try hard coding it? "if I had a handshake issue I guess I would have a different error?" its not a handshake issue, it could simply be that you are accessing port 80 which 404s when you should be using 443 or vise versa. Hard coding the protocol and port will allow you to check this off the list and change the config if needed. Commented Sep 23 at 17:50

1 Answer 1

0

It seems like the new, https proxy was giving a hard time to most of the libs I tried: Net::HTTP, httpclient, httprb but always got "ConectionFailed" ou "unsupported proxy".

Then I read about Typheos, which is based on libcurl and gave it a try, still via a Faraday adapter. Switching to Typheos without changing anything in my code solved the issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.