forcedotcom / EMP-Connector

A simplified cometd connector for Enterprise Messaging Platform
BSD 3-Clause "New" or "Revised" License
185 stars 243 forks source link

Missing Replay ID in subscription #41

Closed jc7447 closed 6 years ago

jc7447 commented 6 years ago

Hi,

When using replay IDs, after receiving a 401 errors during connect, EMP tries to reconnect, the connect() method is called and a subscription is attempt.

It fails with the follwing message from the server: DEBUG | o.cometd.client.BayeuxClient.51386e5 | Processing {clientId=5nbgiqfrsirccvmf20obbgdr9sm, channel=/meta/subscribe, id=27, subscription=/topic/topicName, error=400::The replayId for channel {/topic/topicName} wasn't found using the provided replay ID map {{}}. Ensure that the channel name you provided in the replay map is valid and matches the channel name used for subscribing., successful=false}

Indeed the subscribe message was incomplete :

DEBUG | o.c.client.BayeuxClient.51386e5 | Sending messages [{ext={replay={}}, clientId=5nbgiqfrsirccvmf20obbgdr9sm, channel=/meta/subscribe, id=10, subscription=/topic/topicName}]

I think it's because the connect() method calls replay.clear() which is used by ReplayExtension to set the replay ID in the subscription message.

Its seems that a failed subscription should throw a CannotSubscribe Exception, but I can't see any trace of that in my logs (not sure why).

pbn-sfdc commented 6 years ago

Fixed by the 98bce92f001ede1a3df61047e1011dc4ae728a46

alpha-bytes commented 5 years ago

I'm still receiving this exception when implementing the empApi aura component: EMP API Error: {"clientId":"8gkee6ugvzlbbu8gbxskvke3875","channel":"/meta/subscribe","id":"575","subscription":"/s/notifications/notification","error":"400::The replayId for channel {/s/notifications/notification} wasn't found using the provided replay ID map {{}}. Ensure that the channel name you provided in the replay map is valid and matches the channel name used for subscribing.","successful":false}

I am registering the error callback and subscribing to an event during the initialization phase of the Lightning Component. The documentation doesn't state that this is disallowed - but could the error be lifecycle-related?

Interestingly, the Promise returned by the component's subscribe() method resolves successfully, stating that I am subscribed to the prescribed channel, but then the onError() callback function fires with the message above.