5

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

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.

I had tried putting listeners to log and in the logs it says below

{"clientId":"f6xo67iet55w5j7ek6ldw72nfc6","channel":"/meta/connect","id":"82","successful":true} 5/15/2018 8:12:28 PM

{"advice":{"interval":0,"reconnect":"handshake"},"channel":"/meta/connect","id":"83","error":"403::Unknown client","successful":false} 5/15/2018 8:12:28 PM

{"clientId":"hbx1v2cxebbeder11s99dqkxmasre","advice":{"interval":0,"timeout":110000,"reconnect":"retry"},"channel":"/meta/connect","id":"85","successful":true} 5/15/2018 8:12:29 PM

{"clientId":"hbx1v2cxebbeder11s99dqkxmasre","channel":"/meta/connect","id":"86","successful":true} 5/15/2018 8:14:20 PM

{"clientId":"hbx1v2cxebbeder11s99dqkxmasre","channel":"/meta/connect","id":"87","successful":true} 5/15/2018 8:16:10 PM

so as per the log, sometimes I get "403::Unknown client" but immediately after that it says again channel successful.

But as I said when I try updating the Salesforce object after 2 hours (as per log, it is in connection successful) I am not receiving any notification.

If I restart my windows service and gets the notification again.

In my client I am using cometd from - https://github.com/couchand/CometD.NET/tree/headers and for push topics subscription I am using this - https://github.com/foluis/Salesforce_PushTopics

Any help would be greatly appreciated.

Peter W
  • 952
  • 8
  • 18
Guru Prasad
  • 569
  • 6
  • 13

1 Answers1

4

Ok finally I could able to get this working. Below are the changes

  1. Whenever there is a "403::Unknown client", CometD tries to reconnect (default behavior of cometd)
  2. Once it reconnects, all the channel subscriptions will be removed (which is what cometd does, its a default behavior)
  3. So, the solution is, we always need to do channel subscription inside "meta/Handshake" callback. This is what even cometd.org also recommends to do.
  4. This will ensure that on every handshake channels will be in sync
  5. After doing this my salesforce sync was working fine even if we don't update any object from salesforce and then try after 2 days it still works.
Guru Prasad
  • 569
  • 6
  • 13
  • Great info ! Are you using a .net CometD implementation for this ? Thanks! – federom Aug 01 '18 at 12:45
  • 1
    @federom - Yes. As I had mentioned above - https://github.com/couchand/CometD.NET/tree/headers – Guru Prasad Aug 03 '18 at 10:49
  • 1
    I created some events in the Bayeux client to push the error. Then from my app i detect when the error occurs and i create a new client, handshake and i subscribed to the events. That seems to work! Thanks !! – federom Aug 07 '18 at 19:26
  • @GuruPrasad currently i am facing the same - is is possible to send over a sample code – Thennarasan Feb 27 '19 at 12:37
  • @Thennarasan - sorry did not see this from quite sometime. If you still need the info can send you the code. Let me know. – Guru Prasad Jul 03 '19 at 13:08
  • @GuruPrasad we are also facing same issue, can you please provide a sample code for implementing channel subscription inside "meta/Handshake" callback. – Hrishikesh T T Nov 25 '19 at 12:15
  • @HrishikeshTT - share me your email and i can send you the code. FYI code is written in c# – Guru Prasad Nov 28 '19 at 12:16
  • @GuruPrasad Did you find out the reason behind those 2-3h interval? We have something similar and I am very curious to understand the reason for that regularity. Thank you. – filias Feb 25 '20 at 08:31
  • @filias - Yes as I had briefed in my answer, we need to write our code for subscription to the pushtopics inside meta/handshake callback always, so that connectivity will stay always. Let me know if this answers your question? – Guru Prasad Feb 26 '20 at 14:07