davsclaus opened a new pull request, #30868: URL: https://github.com/apache/camel/pull/30868
Fixes [CAMEL-27569](https://issues.apache.org/jira/browse/CAMEL-27569). ## Problem The `sendTimeout` of an undertow WebSocket producer was passed to Undertow only for `byte[]` and `InputStream` bodies. A `String` or `Reader` message, which is the common case, had no timeout at all. Against a peer that stopped reading, every text send stayed queued in Undertow, together with its exchange. The reporter saw about 1.1 million pending sends fill a 4.4 GB heap. While writing the test, a second problem showed up, and it also affects binary messages today. When Undertow's own timeout fires, it closes the frame and then calls `complete()`, not `onError()`: `flush()` on a closed frame returns `true`. So a timed-out message was dropped while the exchange succeeded. The same send was also reported up to three times. ## Change - `CamelWebSocketHandler` runs the send timeout itself for every message type (`SendTimeoutCallback`). The timer runs on the IO thread of the channel, and only the first outcome is reported: the timeout, or the completion or failure of the write. - When a message is not sent to a peer within `sendTimeout`, the exchange fails with a `CamelExchangeException` caused by a `TimeoutException`, and the connection to that peer is closed. Closing the connection releases the messages that wait for it, so a stalled peer no longer fills the heap. `sendTimeout=0` means no timeout. - When several peers fail, the error message now puts a `: ` between the connection key and the cause. - The `sendTimeout` option description and the 4.24 upgrade guide describe the new behaviour. ## Tests `UndertowWsProducerSendTimeoutTest` opens a raw WebSocket connection that stops reading after the handshake, then sends a 64 MB `String`, `Reader`, `byte[]` and `InputStream` with `sendTimeout=1000`. Each exchange must fail with a `TimeoutException`, and the server must close the connection. - On `main`, the `String`/`Reader` cases hang (`future.get` times out after 30 s), and the `byte[]`/`InputStream` cases complete without an exception. - With this change, all 4 pass, and so does the whole `camel-undertow` module (301 tests). _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
