Good way for the client to know when a Twilio Capability Token has expired

萝らか妹 提交于 2019-12-02 23:59:35

The technique you mentioned using setTimeout() is a completely valid way to manage this. Since your application sets the expiry time, you can set a future function call that coincides to request a new token.

Alternately, if you prefer a callback you can implement Twilio.Device's offline handler. This is called when the token expires, or the Internet connection drops. Either way you'll need a new token to re-establish your offline Client's connection to Twilio.

You can read more about Twilio.Device callbacks in the documentation or Skills Training.

For new people who come across this question, Twilio.Device.error is called with error code 31205 when the token expires.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!