Skip to content

Make sure http connections have a timeout and throw an exception - #1067

Closed
ehoogerbeets wants to merge 5 commits into
box:upstream-patchedfrom
ehoogerbeets:fixWebProxySupport
Closed

Make sure http connections have a timeout and throw an exception#1067
ehoogerbeets wants to merge 5 commits into
box:upstream-patchedfrom
ehoogerbeets:fixWebProxySupport

Conversation

@ehoogerbeets

@ehoogerbeets ehoogerbeets commented Jul 24, 2026

Copy link
Copy Markdown
Contributor
  • We were attempting to use the Basic tunneling scheme to talk to webproxy, but the JDK turns it off by default, so queries through our webproxy server were silently hanging
  • This PR puts a 30 second timeout on the http connection and throws an exception that makes it into the logs so that we aren't wondering what happened. No more silent failure!

- We were attempting to use the Basic tunneling scheme to talk to
  webproxy, but the JDK turns it off by default, so queries
  through our webproxy server were silently hanging
@ehoogerbeets
ehoogerbeets requested a review from wadimw July 24, 2026 01:37
@ehoogerbeets ehoogerbeets self-assigned this Jul 24, 2026
@wadimw

wadimw commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

I think we shouldn't implicitly mess with JDK's security defaults. It makes sense to add -Djdk.http.auth.tunneling.disabledSchemes= to our internal deployment launch args (since this is an isolated environment), but not here.

Since you didn't provide too much context, please confirm if Cursor-assisted justification of your PR is correct:

If so, I think this PR should be converted to add a connection timeout to the HttpClient.Builder in OpenAIHttpClientFactory (with a comment that explains a possible reason for this hangup).

@ehoogerbeets

Copy link
Copy Markdown
Contributor Author

We originally found this problem by running the AiTranslateServiceTest tests which are integration tests. These are skipped if the proxy information is missing in the application.properties. When we provided our proxy credentials and ran again, sure enough, we get the silent hang. We eventually figured out it was because of the Basic scheme disablement.

I originally thought it was the JDK side that wanted to talk to the webproxy server with Basic sheme. However, it turns out that it is actually our proxy server that is requiring it.

SO, we're going to update this so that you can put something like "useBasic" in the proxy settings in application.properties and it will re-enable Basic by itself. That way, it stays off by default, and you can explicitly turn it on again if your environment requires it.

Also, we'll put the timeout in for safety.

ehoogerbeets and others added 3 commits July 24, 2026 15:34
Introduce l10n.webproxy settings with per-service overrides for backward
compatibility, an opt-in for Basic auth on HTTPS CONNECT, and a default
connect timeout so unreachable proxies fail quickly instead of hanging.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@ehoogerbeets ehoogerbeets changed the title Don't disable "Basic" tunneling scheme Make sure http connections have a timeout and throw an exception Jul 27, 2026
// TEST-NET-1 (RFC 5737) — should not be routable; connection establishment must time out.
HttpRequest request =
HttpRequest.newBuilder()
.uri(URI.create("http://192.0.2.1:81/"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better/more Java-idiomatic way to trigger failure than hardcoding a specific URL? maybe like a mock connection or something

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor says:

192.0.2.1 is not a normal local/LAN address.

It comes from TEST-NET-1 (192.0.2.0/24), reserved by RFC 5737 for documentation and examples. IANA marks that block as special-use; it must not be routed on the public Internet, and the RFC says these blocks are not for local use. Operators are expected to treat them as non-routable / filter them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the comment above it to make it more clear what this IP address is all about and give the link to the RFC for it.

@wadimw wadimw added the upstream-patched Experimental features ported from legacy branch label Jul 30, 2026
@wadimw

wadimw commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

This is also superceded by #1070 right?

@ehoogerbeets

Copy link
Copy Markdown
Contributor Author

Yes, I'll close it.

@ehoogerbeets
ehoogerbeets deleted the fixWebProxySupport branch July 30, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upstream-patched Experimental features ported from legacy branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants