Session handlers not being called

I tried setting up the session handlers following this guide Authentication | Chat JavaScript SDK | Sendbird Docs

The session handler is set up before opening the connection as instructed in the documentation.

The scenario that I want to handle is when a session token is expired or revoked, so I could request for a new session token and call onSuccess in the onSessionTokenRequired handler.

Currently none of the events are triggered when I revoke the token, or when I purposely issue a short-lived token and wait for it to expire.

What I noticed is, both these scenarios (revoked or expired token) triggers the onReconnectStarted event instead, but that’s not what I need, as it will only keep on retrying to connect which fails because the token is no longer valid.

Any idea what could be the issue?

Hi @hewong,

I actually discovered this a few days ago and am currently working with our Engineering team to resolve this in the Javascript SDK.I will update here once they have been resolved.

1 Like

Hi @Tyler, would like to know if this has been fixed? Thanks!

Hi @hewong,

We’ve completed the work internally and are just waiting for it to be released. I’ll post here when the version that includes the fix has been released. I apologize for the delay!

1 Like

Hi @hewong Good news, this was released in version 3.1.10 which was released today. Please give it a try and let me know if you’re running into any issues.

Thanks for the update @Tyler, will give it a try!

Hi @Tyler , I’ve upgraded to v3.1.10 and tried the session handlers again.

From what I understood from the documentation (correct me if i’m wrong), onSessionTokenRequired should be triggered when a session token expires during a session, so I could request a new session token and pass it into the onSuccess callback to refresh the session.

This is what I did:

  1. set up session handlers
  2. connect to sendbird with a valid session token
  3. wait for session token to expire

I expect onSessionTokenRequired to be triggered when the token expires, but onSessionError was triggered instead.

Did I understand the handlers correctly or did I miss anything here?

Hi @hewong,

Could you share with me some code examples on how you’re implementing the sessionHandlers? Feel free to DM me if you’d prefer.

Hi @Tyler , I am on sdk version 4.0.3 and still experiencing the same issue. Please check the following snippet. The onSessionRequired never gets called when a session expires.

Hi @kavindu_tinto,

I’ll look at this as soon as possible and let you know what I find.

Hi @kavindu_tinto,

Just a quick update. I was able to reproduce the behavior and am working with our Engineering team to address it.