0

I am developing BrowserPhone by twilio.js, version is 1.4.20.

When token expired, I am handling Twilio.Device.offline(), and regenerate token and re-setup Twilio.Device.

After 6 times re-setup, then, Twilio.js throw error.

*Failed* to construct 'AudioContext': The number of hardware contexts provided (6) is greater than or equal to the maximum bound (6).

How can I prevent this error?

I'm using these code.

Twilio.Device.offline((device) => {
if (navigator.onLine) {
    Twilio.Device.destroy();
    Twilio.Device.instance = null;
    getToken(device._clientName);
}

const getToken = (identity) => {
$.ajax({
    type: 'POST',
    url: baseurl + '/token/get',
    data: {'identity': identity}
})
.done((data) => {
    data = JSON.parse(data);
    Twilio.Device.setup(data.token, {
        closeProtection: true
    });
};
  • What is the code you are using to handle the offline event, regenerate the token and run setup again? – philnash Jul 25 '17 at 13:12
  • Thanks for reply.I'm using these code. ``` Twilio.Device.offline((device) => { if (navigator.onLine) { Twilio.Device.destroy(); Twilio.Device.instance = null; const client_name = device._clientName; getToken(client_name); } ``` ``` const getToken = (identity) => { $.ajax({ type: 'POST', url: baseurl + '/token/get', data: {'identity': identity} }) .done((data) => { data = JSON.parse(data); Twilio.Device.setup(data.token, { closeProtection: true }); }; ``` – 西口瑛一 Jul 25 '17 at 23:58
  • Sorry, still looking into this at the moment. Which browser are you experiencing this in? – philnash Jul 26 '17 at 13:09
  • Hey, is this application running in more than one browser tab at the same time too? Thanks – philnash Jul 26 '17 at 14:56
  • Thanks for reply. I'm developing Chrome Extension.Application is single device running.I think twilio.js in L.86 every time instance AudioContext makes exception.I tried Twilio.Device.destroy() before setup, but exception still thrown:( – 西口瑛一 Jul 27 '17 at 10:51

0 Answers0