-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] tokenWillExpire listener being triggered just once #93
Comments
Hi @bgalartza, we've created a ticket for the team to track internally. Thanks for bringing this one up! |
@bgalartza we're seeing this behavior in our testing:
|
Hello,
Or are we missing something in the sample piece of code that we provided? Thank you |
Hi @bgalartza to understand better wether this is a bug or not, we need to know the timestamps between each step. Right before you call |
@bgalartza can you please provide the above information? Or is this not an issue anymore? |
Hello: token1 = "xxx"
token2 = "yyy"
console.log(Date.now())
dev = new Twilio.Device(token1, {logLevel: 1, debug: true, tokenRefreshMs: 30000 })
dev.on('tokenWillExpire', () => {
console.log("Token update")
console.log(Date.now())
dev.updateToken(token2);
});
dev.on('error', (twilioError, call) => {
console.log('An error has occurred: ', twilioError);
console.log(Date.now())
});
dev.connect(); And the results are: I would say they look OK: |
Thanks @bgalartza for the additional information.
Does this mean the behavior is what you expect and we can close this now? |
Hello, |
Is there a fix for this issue, we see this behaviour @bgalartza described in our code as well. Thanks |
Hey everyone, sorry for the late response. We're bumping this up in priority and we'll take a look in the next few sprints. |
Hey everyone, sorry for the delay in response. We are still not able to reproduce this issue even after using the code provided in this ticket. Are you still seeing this issue in the latest version of the SDK (v2.10.1)? If yes:
|
or sensitive account information (API keys, credentials, etc.) when reporting this issue.
Code to reproduce the issue:
In order to reproduce the issue at least two tokens are needed. To simplify the steps, both tokens were created just before execution the code.
Expected behavior:
The
tokenWillExpire
listener should be triggered twice:So:
"Token update"
string should be printed twice in the console.token2
would be expired. In reality that should call the BE to obtain a third token, but it was done like that to simplify the code. It's not important for this demo because the code is never executed for the second time.Actual behavior:
The listener is called just once, and the
"Token update"
string is printed once.The first time the listener is called as expected:
But there are no more logs after this until
token2
is expired and Twilio complains about the expired AccessTokenBy giving a quick look to the related code I understand that the timer is only initialized when the
connected
event happens. So the timer is stopped after the first listener trigger, and it's not re-initialized again until a new connection happens. I might be missing something, but maybe the timeout should be initiated after the token update too?Also, I would expect that the timer is initialized just after you init the
Device
object, and not when a new call is started. Because it might happen that the access-token is already expired when trying to create an outgoing call or registering for incoming ones.Software versions:
The text was updated successfully, but these errors were encountered: