[
https://issues.apache.org/jira/browse/CAMEL-25251?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-25251:
--------------------------------
Fix Version/s: 4.23.0
> camel-coap - the producer completes the exchange successfully when the CoAP
> server does not respond (timeout or rejected request), so the message is
> silently lost
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-25251
> URL: https://issues.apache.org/jira/browse/CAMEL-25251
> Project: Camel
> Issue Type: Bug
> Components: camel-coap
> Reporter: shashank
> Priority: Minor
> Fix For: 4.23.0
>
>
> {{CoAPProducer.process}} sends the request with the synchronous
> {{CoapClient}} methods ({{get}}, {{post}}, {{put}}, {{delete}}). These return
> {{null}} when no response is received: the request timed out after the CoAP
> retransmissions (62 to 93 s with the defaults {{ACK_TIMEOUT=2s}},
> {{ACK_INIT_RANDOM=1.5}}, {{MAX_RETRANSMIT=4}}, or the client {{timeout}}), or
> it was rejected or cancelled. The producer only handles a non-null response:
> {code:java}
> if (response != null) {
> CoAPHelper.convertCoapResponseToMessage(response, exchange.getOut());
> }
> {code}
> so in that case the exchange completes *without an exception*, with the
> request still as its body and no {{CamelCoapResponseCode}} header. A route
> that posts readings to a CoAP server that is down or unreachable reports
> every message as delivered; redelivery, dead letter channels and
> {{onException}} never see the failure.
> Two smaller defects in the same method: the {{CamelCoapMethod}} header is
> matched case-sensitively ({{"post"}} matches no case and nothing is sent at
> all, again without an error), while the PING check below it ignores the case.
> h3. Reproduction
> {code:java}
> CoapClient client = new CoapClient("coap://localhost:<unused
> port>/TestResource").setTimeout(500L); // bound as noAnswerClient
> from("direct:start")
> .to("coap://localhost:<unused port>/TestResource?client=#noAnswerClient")
> .to("mock:result");
> {code}
> {{template.request("direct:start", e -> e.getIn().setBody("Hello"))}} returns
> an exchange without exception (and {{mock:result}} receives "Hello"). The
> same happens without the shared client, after the default retransmission
> timeout. A unit test fails on main.
> h3. Proposed fix
> When the client returns no response for {{GET}}/{{POST}}/{{PUT}}/{{DELETE}},
> fail the exchange with {{CamelExchangeException("No response received from
> CoAP server: <uri>")}}. {{PING}} keeps its boolean body (false when there is
> no answer). The method header is upper-cased before the switch, and an
> unknown method fails with {{IllegalArgumentException}} instead of sending
> nothing. With the fix the new test and the whole camel-coap suite pass (74
> tests). The upgrade guide gets a note because such exchanges now fail.
> Affected: 4.14.x, 4.18.x and main (same code since the component was written).
> Duplicate check (2026-10-01): JIRA component camel-coap (26 issues) and text
> "coap" with "timeout", "no response", "null response": CAMEL-12030,
> CAMEL-12029, CAMEL-12033 (producer options and response code), nothing about
> a missing response. GitHub pull requests "coap": none about the producer.
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)