shashank created CAMEL-27506:
--------------------------------

             Summary: camel-xmpp - with testConnectionOnStartup=false the 
consumer stops trying to start after one failed login or room entry, and the 
route stays Started without consuming
                 Key: CAMEL-27506
                 URL: https://issues.apache.org/jira/browse/CAMEL-27506
             Project: Camel
          Issue Type: Bug
          Components: camel-xmpp
            Reporter: shashank
            Assignee: shashank


h3. What happens

With {{testConnectionOnStartup=false}}, a consumer that cannot reach the server 
at start schedules a delayed start, which runs {{doStart}} again every 
{{connectionPollDelay}} seconds. It only tries again when getting the 
connection throws a {{SmackException}} (server not reachable). Any other 
failure ends the delayed start for good: the task catches it, logs "Ignoring an 
exception caught in the startup connection poller thread." and nothing 
schedules another attempt. The connection monitor is only started at the end of 
a successful start, so nothing else retries either.

Failures that end it once the server is reachable again:
* the login fails with an {{XMPPException}} (for example SASL 
{{temporary-auth-failure}} while the authentication backend of the server is 
not up yet);
* entering the room fails ({{XMPPErrorException}} such as 
{{service-unavailable}} while the MUC service is not ready, or a 
{{NoResponseException}} / {{NotConnectedException}} when the connection drops 
during the join).

The route stays Started and receives nothing until it is restarted by hand. The 
failure does not reach the consumer's exception handler. A room consumer also 
keeps the account's connection (it stays a user of the shared connection) while 
it is not in its room. This contradicts the option's documentation, which says 
the consumer polls for a connection until it is established.

h3. How to reproduce

A room consumer with {{testConnectionOnStartup=false}} and 
{{connectionPollDelay=1}}, server down at start. When the server is up, it 
refuses the first room entry with {{service-unavailable}} and accepts the next 
ones: after 8 s there was exactly one entry attempt, the consumer is not in the 
room, a room message is lost, the route is Started. The same with a chat 
consumer whose first SASL login fails with {{temporary-auth-failure}}: one 
login attempt, no session.

Found with a TLA+ model of the consumer's delayed start and connection monitor 
("a Started consumer is subscribed or a retry is scheduled" fails), and 
reproduced against the real consumer with a small fake XMPP server.

h3. Fix

The delayed start tries again after any failure, with the same delay 
({{connectionPollDelay}}), until the consumer is stopped. Before the next 
attempt it releases what the failed attempt got (its listeners on the 
connection, the room, its use of the shared connection), so a consumer that is 
not started does not hold the account's connection. The first failure is logged 
at WARN with the stack trace and passed to the exception handler, the next ones 
at DEBUG; a start that works after failed attempts logs one INFO line. 
{{XmppEndpoint.createConnection}} closes a new connection whose connect or 
login fails (Smack keeps it open and nobody else has it), so the retried logins 
do not leave one open connection per attempt. An {{Error}} is handled the same 
way, a {{VirtualMachineError}} is thrown on (CAMEL-27469). The consumer has no 
health check of its own, so the route status remains the only health signal; a 
consumer health check would be a separate improvement.

_Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to