Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cometd/bayeux client Issue - Implementation of "meta/handshake" call back #26

Open
swagathchandra opened this issue Dec 2, 2020 · 1 comment

Comments

@swagathchandra
Copy link

I have my .NET client (windows service) which subscribes to Salesforce streaming API CDC.

I am able to connect to Salesforce and can get the notifications to my client. Everything is working fine, but When there is no activity on the channel (no changes for Salesforce object) after some time (maybe 2 hours) if I update the object, I am not receiving any notification from Salesforce. Can anyone please help me, I read in some of previous posts about implementing "meta/callback" but not able to figure out the implementation, below is the code. I will appreciate if anyone can provide me example for implementation of "meta/handshake" to resubscribe the channels

public async Task StartAsync(CancellationToken cancellationToken)
{
appLifetime.ApplicationStarted.Register(OnStarted);
appLifetime.ApplicationStopping.Register(OnStopping);
appLifetime.ApplicationStopped.Register(OnStopped);

        logger.LogInformation("StreamingService.StartAsync has been called.");

        logger.LogInformation("Authenticating with Salesforce...");
        var authToken = await salesforceClient.GetToken();

        logger.LogInformation("Enabling Bayeux protocol...");
        var options = new Dictionary<String, Object>
        {
           { ClientTransport.TIMEOUT_OPTION, readTimeOut }
        };

        var headers = new NameValueCollection { { "Authorization", "OAuth " + authToken.AccessToken } };
        var transport = new LongPollingTransport(options, headers);
        var serverUri = new Uri(authToken.InstanceUrl);
        var endpoint = $"{serverUri.Scheme}://{serverUri.Host}{sfOptions.StreamEndpoint}";

        bayeuxClient = new BayeuxClient(endpoint, new[] { transport });
        logger.LogInformation("Handshaking with Salesforce stream...");
        bayeuxClient.Handshake();
        bayeuxClient.WaitFor(1000, new[] { BayeuxClient.State.CONNECTED });
        logger.LogInformation("Connected to Salesforce stream...");
        bayeuxClient.GetChannel(sfOptions.Channel).Subscribe(new Listener(logger));
        logger.LogInformation("Waiting for data from server...");
    }
@PierreC82
Copy link

PierreC82 commented Dec 3, 2022

Did you solve the problem?
I have exactly the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants