Bartosz Popiela created CAMEL-20388:
---------------------------------------

             Summary: Salesforce component does not handshake on the connection 
failure
                 Key: CAMEL-20388
                 URL: https://issues.apache.org/jira/browse/CAMEL-20388
             Project: Camel
          Issue Type: Bug
          Components: camel-salesforce
    Affects Versions: 3.22.1
            Reporter: Bartosz Popiela


When using the Salesforce component to consume platform events, we observe the 
following warning message printed every 3 hours:
{noformat}
Connect failure: {advice=
{reconnect=handshake, interval=0}
, channel=/meta/connect, id=2005814, error=403::Unknown client, 
successful=false}
{noformat}
According to 
[this|https://help.mulesoft.com/s/article/Couldn-t-connect-to-Salesforce-streaming-server-because-a-403-error-has-been-returned-error-403-Unknown-client-Warning-messages-in-log]
 article, it is caused by the expiring sfdc-stream cookie used by CometD. When 
it happens, the client is expected to  perform a new handshake and re-subscribe 
to the channels. This is handled in connectListener 
(_org.apache.camel.component.salesforce.internal.streaming.SubscriptionHelper#initMessageListeners_).
 Unfortunately, because the client is in the CONNECTED state when this message 
is received, the 
{code:java}
        while (!abort && !client.isDisconnected()) {
            try {
                Thread.sleep(DISCONNECT_INTERVAL);
            } catch (InterruptedException e) {
                LOG.error("Aborting handshake on interrupt!");
                abort = true;
            }

            abort = abort || isStoppingOrStopped();
        }
{code} condition 
(_org.apache.camel.component.salesforce.internal.streaming.SubscriptionHelper#doHandshake_)
 and it stays in the handshaking state indefinitely 
(_org.apache.camel.component.salesforce.internal.streaming.SubscriptionHelper#handshaking_),
 hence the handshake won't be performed for neither first nor any consecutive 
message of this kind. This bug was possibly introduced by 
[this]([https://github.com/apache/camel/commit/7a6315a73569f92a234a948a11cf4fc5478701c0#diff-fd8ac20f7b12e53a2e26d69754c9496a1c374377650c36979ac1d6d52c80fbe0]
 ) commit, which removed

{code:java}
client.disconnect();
{code}

from connectListener 
(org.apache.camel.component.salesforce.internal.streaming.SubscriptionHelper:178_).
 As a consequence, after couple of days the client stops receiving Salesforce 
events.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to