[
https://issues.apache.org/jira/browse/CAMEL-27491?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18150482#comment-18150482
]
Claus Ibsen commented on CAMEL-27491:
-------------------------------------
A friendly reminder: fixing bugs is a priority, and the Camel 4.24.0 release is
coming up. If you cannot work on this ticket before then, please unassign it so
someone else can pick it up.
_Claude Code on behalf of Claus Ibsen (davsclaus)_
> camel-smpp - a bind the SMSC rejects while the consumer or producer starts
> runs the reconnect inside start(): the start does not return and a stop waits
> for it
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27491
> URL: https://issues.apache.org/jira/browse/CAMEL-27491
> Project: Camel
> Issue Type: Bug
> Components: camel-smpp
> Reporter: shashank
> Assignee: shashank
> Priority: Major
>
> h3. What happens
> When the SMSC rejects the bind of a consumer or an eager producer during
> {{start()}} (wrong credentials, {{ESME_RALYBND}}, throttling, no
> {{bind_resp}} in time), the start does not return with the default
> {{maxReconnect}} ({{Integer.MAX_VALUE}}), for as long as the SMSC keeps
> rejecting:
> * jsmpp closes a session whose bind fails on the thread that called
> {{connectAndBind}}, and calls the session state listeners on that thread
> before {{connectAndBind}} throws ({{SMPPSession.connectAndBind}}, the catch
> blocks call {{close()}}).
> * The Camel listener is registered before the bind, so it runs on the
> starting thread, sees a lost session and runs the reconnect task there.
> {{BackgroundTask.run}} waits for the task with no time limit, while the
> starting thread holds the lifecycle lock of the service.
> * {{stop()}} from another thread (route controller, shutdown) waits for the
> same lock, so the cancellation added by CAMEL-27090 cannot run.
> * When the SMSC accepts again, the reconnect binds a session, and then
> {{connectAndBind}} throws anyway ("Receive negative bind response"): the
> start fails, and the stop that follows unbinds the session the reconnect just
> made.
> When the SMSC closes the connection right after its negative {{bind_resp}},
> jsmpp's reader thread often reports the close instead (21 of 30 binds in a
> test-JVM probe); the reconnect then runs on the reader thread and the start
> is not held by it, but jsmpp can drop the {{bind_resp}} and the bind fails
> only after its fixed 60 s wait.
> A lazy producer ({{lazySessionCreation=true}}) holds the route thread in
> {{process()}} the same way: {{connectLock}} is reentrant, so the listener
> that runs inside the lazy session creation gets it again and runs the whole
> reconnect task on the route thread.
> h3. How to reproduce
> An SMSC in the test JVM (jsmpp {{SMPPServerSessionListener}}) that answers
> every bind with {{ESME_RBINDFAIL}}, endpoint with {{reconnectDelay=100}}:
> {{consumer.start()}} has not returned after 3 s (19 binds rejected by then),
> {{stop()}} from another thread has not returned 3 s later; once the SMSC
> accepts, one session is bound and then {{start()}} fails with {{IOException:
> Receive negative bind response}}. The same with an eager producer, and with
> {{process()}} of a lazy producer.
> Found with a TLA+ model of the reconnect (lifecycle thread, stopper,
> reconnect thread, jsmpp reader threads, route threads, an SMSC that rejects,
> refuses and drops).
> h3. Fix
> The listener ignores a close that is reported, on the thread that is binding
> the session, for that session (the consumer and the producer remember per
> thread the session whose {{connectAndBind}} runs on it). The caller of
> {{connectAndBind}} handles the failure: the start fails with the bind error
> as soon as {{connectAndBind}} throws (at once for a negative {{bind_resp}},
> after jsmpp's fixed 60 s bind wait when the SMSC does not answer), as when
> the SMSC refuses the connection (CAMEL-6616 asked for a start that gives up;
> its fix added {{maxReconnect}}, but with the default the start kept waiting);
> a lazy producer fails the exchange and tries again with the next one; a
> reconnect attempt fails and the task tries again after {{reconnectDelay}}, as
> before. A session lost after it was bound is reconnected as before.
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)