Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout with HTTPX + Faraday through a proxy results in SSLError #69

Open
sabribrn opened this issue Jan 16, 2025 · 0 comments
Open

Timeout with HTTPX + Faraday through a proxy results in SSLError #69

sabribrn opened this issue Jan 16, 2025 · 0 comments

Comments

@sabribrn
Copy link

Hi 👋

It seems there is an issue with HTTPX, when used with Faraday, a proxy and when a timeout happens.

This snipppet should return a Faraday::TimeoutError but instead it returns a Faraday::SSLError:

Faraday.new(:ssl => { :ca_path => "/usr/lib/ssl/certs" }) do |conn|
  conn.url_prefix = "https://httpstat.us"
  conn.adapter :httpx
  conn.options.timeout = 1
  conn.proxy = "http://myproxy@myuser:33333"
end.get("/200?sleep=1200")

It triggers a request against https://httpstat.us/200?sleep=1200 which, with a timeout of 1sec, will time out.
Using httpx as adapter, it always return a SSLError:

SSL_connect returned=1 errno=0 peeraddr=10.140.0.88:443 state=error: certificate verify failed (self-signed certificate in certificate chain)

The same snippet, with a different adapter like net_http or http return the right error Faraday::TimeoutError.

More context

Gem versions

faraday 2.12.2
httpx 1.4.0

Previous bug

Previous to HTTPX v1.3.2, that snippet would have returned :

undefined method `empty?' for nil:NilClass (NoMethodError)

             __proxy_error?(response) && !@_proxy_uris.empty?

and that bug was solved here.

Certificate

Passing or not the certificate explicitly (:ssl => { :ca_path => "/usr/lib/ssl/certs" })) doesn't change the outcome

HTTPX only

Oddly enough, HTTPX without Faraday returns the right error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant