[ 
https://issues.apache.org/jira/browse/CAMEL-20388?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Bartosz Popiela updated CAMEL-20388:
------------------------------------
    Description: 
We use the Salesforce component to consume platform events and every 3 hours we 
observe the following warning message:
{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 
(_SubscriptionHelper#initMessageListeners_). Unfortunately, because the client 
is in the CONNECTED state when this message is received, the condition
{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} (_SubscriptionHelper#doHandshake_) is not met and it stays in the 
handshaking state indefinitely (_SubscriptionHelper#handshaking_), hence the 
handshake is not being performed. As a consequence, after a couple of days the 
client stops receiving Salesforce events.

This bug may have been introduced by 
[this|https://github.com/apache/camel/commit/7a6315a73569f92a234a948a11cf4fc5478701c0#diff-fd8ac20f7b12e53a2e26d69754c9496a1c374377650c36979ac1d6d52c80fbe0]
 commit, which removed
{code:java}
client.disconnect();
{code}
from connectListener (_SubscriptionHelper:178_).

  was:
We use the Salesforce component to consume platform events and every 3 hours we 
observe the following warning message:
{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 
(_SubscriptionHelper#initMessageListeners_). Unfortunately, because the client 
is in the CONNECTED state when this message is received, the condition
{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} (_SubscriptionHelper#doHandshake_) is not met and it stays in the 
handshaking state indefinitely (_SubscriptionHelper#handshaking_), hence the 
handshake will not be performed.  This bug may have been introduced by 
[this|https://github.com/apache/camel/commit/7a6315a73569f92a234a948a11cf4fc5478701c0#diff-fd8ac20f7b12e53a2e26d69754c9496a1c374377650c36979ac1d6d52c80fbe0]
 commit, which removed
{code:java}
client.disconnect();
{code}
from connectListener (_SubscriptionHelper:178_). As a consequence, after couple 
of days the client stops receiving Salesforce events.


> 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
>            Priority: Major
>
> We use the Salesforce component to consume platform events and every 3 hours 
> we observe the following warning message:
> {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 
> (_SubscriptionHelper#initMessageListeners_). Unfortunately, because the 
> client is in the CONNECTED state when this message is received, the condition
> {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} (_SubscriptionHelper#doHandshake_) is not met and it stays in the 
> handshaking state indefinitely (_SubscriptionHelper#handshaking_), hence the 
> handshake is not being performed. As a consequence, after a couple of days 
> the client stops receiving Salesforce events.
> This bug may have been introduced by 
> [this|https://github.com/apache/camel/commit/7a6315a73569f92a234a948a11cf4fc5478701c0#diff-fd8ac20f7b12e53a2e26d69754c9496a1c374377650c36979ac1d6d52c80fbe0]
>  commit, which removed
> {code:java}
> client.disconnect();
> {code}
> from connectListener (_SubscriptionHelper:178_).



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

Reply via email to