[
https://issues.apache.org/jira/browse/CAMEL-23345?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18081811#comment-18081811
]
Claus Ibsen commented on CAMEL-23345:
-------------------------------------
After further investigation, here is a summary of findings:
*Root Cause:*
HTTPClient5 version 5.5.x introduced RFC 7231-compliant {{Retry-After}} header
handling in {{DefaultServiceUnavailableRetryStrategy}}. The release notes for
5.5.1 state:
{quote}RFC 7231: DefaultServiceUnavailableRetryStrategy to take Retry-After
header value into account if specified{quote}
Camel bumped httpclient5 from 5.4.4 to 5.5.1 in Camel 4.18.x, which is why the
hang started appearing from that version onwards. The test endpoint at
mock.httpstatus.io/429 returns {{Retry-After: 3600}}, so HTTPClient5 parks the
request for 1 hour before retrying.
*Existing Workaround (component option):*
The {{camel-http}} component already has an {{automaticRetriesDisabled}} option
(advanced, default=false) that can be used to disable the retry behavior
entirely:
{code:java}
// Via component option
HttpComponent httpComponent = context.getComponent("https",
HttpComponent.class);
httpComponent.setAutomaticRetriesDisabled(true);
{code}
Or via URI option: {{https://...?automaticRetriesDisabled=true}}
This is equivalent to the workaround already found by the reporter.
*Related tickets:*
- [HTTPCLIENT-2421|https://issues.apache.org/jira/browse/HTTPCLIENT-2421] -
upstream ticket filed at httpclient
- [CAMEL-23375|https://issues.apache.org/jira/browse/CAMEL-23375] - upgrade to
httpclient5 5.6+ (currently blocked by Rest-Assured incompatibility)
*Possible future improvement:*
A {{maxRetryAfterDelay}} option could be added to allow finer control, e.g.
fail fast when the Retry-After header value exceeds a configured threshold
instead of waiting indefinitely. This would be a middle ground between waiting
and disabling retries entirely.
_Claude Code on behalf of Claus Ibsen_
> Https which returns HTTP Code 429 hangs
> ---------------------------------------
>
> Key: CAMEL-23345
> URL: https://issues.apache.org/jira/browse/CAMEL-23345
> Project: Camel
> Issue Type: Bug
> Components: camel-http
> Affects Versions: 4.19.0
> Reporter: Raymond
> Priority: Minor
> Fix For: 4.x
>
>
> We use integration tests to test several http response code. One of to test
> return :
> {code:java}
> HTTP 429 too many requests.{code}
> To test we use the following mock endpoint:
> [https://mock.httpstatus.io/429]
> You can use this in the browser and it works. It also worked on our Camel
> 4.10.9 server. However, in later versions like 4.18.x and 4.19.0 the http
> request:
> {code:java}
> - to:
> uri: "https://mock.httpstatus.io/429{code}
> I tried various options, but found out it's on lower level, in the
> HTTPClient5. Seems like it stalls when it's doing a TLS handshake (same url,
> but with http that returns a HTTP Code 301) works normally.
> I was workaround it by disabling the retries done by the HTTPClient:
> {code:java}
> HttpComponent httpComponent = context.getComponent("https",
> HttpComponent.class);
> httpComponent.setHttpClientConfigurer(HttpClientBuilder::disableAutomaticRetries);
> {code}
> This solves the issue us for us, but you may want to check it out, because
> it's maybe also an issue for others. Note I'm traveling coming days, so I am
> not able to follow the issues.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)