Make sure http connections have a timeout and throw an exception - #1067
Make sure http connections have a timeout and throw an exception#1067ehoogerbeets wants to merge 5 commits into
Conversation
- 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
|
I think we shouldn't implicitly mess with JDK's security defaults. It makes sense to add 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 |
|
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. |
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>
- based on review comments from Wadim
| // 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/")) |
There was a problem hiding this comment.
Is there a better/more Java-idiomatic way to trigger failure than hardcoding a specific URL? maybe like a mock connection or something
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
This is also superceded by #1070 right? |
|
Yes, I'll close it. |
Uh oh!
There was an error while loading. Please reload this page.