1

I have a lighting component which subscribes to a event channel Notification__e on load. I have used replayId =-2 to read all the old events.

subscribe: function (component, event, helper) {
    const empApi = component.find('empApi');
    const channel = component.get('v.channel');
    const replayId = -2;
    const callback = function (message) {
        console.log('Event Received : ' + JSON.stringify(message));
    };

    // Subscribe to the channel and save the returned subscription object.
    empApi.subscribe(
        channel, 
        replayId, 
        $A.getCallback(callback)
    ).then(
        $A.getCallback(function (newSubscription) {
            console.log(newSubscription);
            component.set('v.subscription', newSubscription);
        })
    );
}

But, on reload, component either gives old events information or it errors out. I could not figure out why it sometimes retrieves old events and sometimes throws out error message. Also, it is giving stored events information which were created on 6th sept but as per doc salesforce stores events for 24 hours.

Old Events

Event Received : {"data":{"schema":"2-WbrEYaxZwZWJVS5I0l9Q",
"payload":{"CreatedById":"0052v00000VcpWtAAJ","Message__c":"Watch out, bear 
 spotted!","CreatedDate":"2019-09-06T09:38:56Z"},"event": 
 {"replayId":1025104}},"channel":"/event/Notification__e"}

Event Received : {"data":{"schema":"2-WbrEYaxZwZWJVS5I0l9Q","payload": 
{"CreatedById":"0052v00000VcpWtAAJ","Message__c":"Watch out, bear 
spotted!","CreatedDate":"2019-09-06T09:39:04Z"},"event": 
{"replayId":1025105}},"channel":"/event/Notification__e"}

Event Received : {"data":{"schema":"2-WbrEYaxZwZWJVS5I0l9Q","payload": 
{"CreatedById":"0052v00000VcpWtAAJ","Message__c":"Watch out, bear 
spotted!","CreatedDate":"2019-09-10T14:10:57Z"},"event": 
{"replayId":1025953}},"channel":"/event/Notification__e"}

Error Messages

{"clientId":"5qi16wx0fqh37geo1sytv4xvwp0qk","advice":{"interval":0,"reconnect":"none"},"channel":"/meta/connect","id":"3","error":"403::Unknown client","successful":false}

{"clientId":"5qjfzyexvvngf1lly1u9ozgp6y5","advice":{"interval":0,"reconnect":"none"},"channel":"/meta/connect","id":"8","error":"403::Unknown client","successful":false}

{"id":"2","successful":false,"channel":"/meta/subscribe","failure":{"reason":"Request 2 of transport long-polling exceeded 10000 ms max network delay","httpCode":0,"connectionType":"unknown","transport":{},"message":{"id":"2","channel":"/meta/subscribe","subscription":"/event/Notification__e","clientId":"5qi16wx0fqh37geo1sytv4xvwp0qk","ext":{"replay":{"/event/Notification__e":-2}}}},"subscription":"/event/Notification__e"}

{"id":"6","successful":false,"channel":"/meta/subscribe","failure":{"reason":"Request 9 of transport long-polling exceeded 10000 ms max network delay","httpCode":0,"connectionType":"unknown","transport":{},"message":{"id":"6","channel":"/meta/subscribe","subscription":"/s/notifications/notification","clientId":"5qjfzyexvvngf1lly1u9ozgp6y5","ext":{"replay":{"/s/notifications/notification":-1}}}},"subscription":"/s/notifications/notification"}

2
  • 2
    Formatting tips: Horizontal scroll bars are bad, when pasting code format it in a way to where there is no horizontal scroll bars if possible. Errors go in quotes (quotes don't have scroll bars). Code formatting is only for code, for headings use "##" in front of your text. For emphasized, non-code, text, use bold.
    – gNerb
    Sep 10, 2019 at 14:58
  • Thanks! Helpful tips.
    – devforce
    Sep 10, 2019 at 19:02

1 Answer 1

4

You're having network connection problems. Please contact your IT department or Internet Provider.

Documentation:

403::Unknown Client: The server deleted the client CometD session due to a timeout, which can be caused by a network failure. The client must perform a new handshake and reconnect.

Both errors suggest that your connection is dropping out for relatively extended periods of time.

Also, as of API 37.0, messages may be stored up to 72 hours.

2
  • Thanks! I can see this information in link that you have shared but it is missing from the trailhead module. It still says events are stored till 24 hours which caused confusion with the retrieved result.
    – devforce
    Sep 10, 2019 at 19:01
  • @devforce It depends on the type of event you're using.
    – sfdcfox
    Sep 10, 2019 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.