twilio / twilio-chat-demo-js

Programmable Chat API Demo Application for JavaScript
BSD 3-Clause "New" or "Revised" License
90 stars 94 forks source link

Chat client reinitialize error #44

Closed dchennaraidu closed 5 years ago

dchennaraidu commented 5 years ago

I have reduced the ttl to 40 seconds tokenprovider.js, but on the client side tokenAboutToExpire event is never getting hit.

So I have added tokenExpired event listener, but unable to update client. (unable to send/retrive messages thereafter)

var token = new AccessToken(this.accountSid, this.signingKeySid, this.signingKeySecret, {
    identity: identity,
    ttl: 40
  });
aleksandrsivanovs commented 5 years ago

Hi!

tokenAboutToExpire is emitted roughly 1 minute before the token expiration - hence, if you will use ttl smaller than 1 minute - then it won't fire. And in general - we don't recommend to use tokens with such small ttl (because of practical reasons). May I ask why do you need token with ttl 40 seconds?

Aleksandrs

dchennaraidu commented 5 years ago

Hi!

tokenAboutToExpire is emitted roughly 1 minute before the token expiration - hence, if you will use ttl smaller than 1 minute - then it won't fire. And in general - we don't recommend to use tokens with such small ttl (because of practical reasons). May I ask why do you need token with ttl 40 seconds?

Aleksandrs

Hi Ivanovs, thanks for the info, and I'm exploring how it works when chat token is expired (so I set 40 to test). Now I increased it to 180

image

tokenAboutToExpire didn't work, tokenExpired worked but even after updating with new token, client is in offline mode

image

dchennaraidu commented 5 years ago

I increased to ttl to 240, tokenAboutToExpire is emitted. Thanks for the help @aleksandrsivanovs