Reputation: 1789
I'm running a node server (v10.12.0) in ubuntu (16.04.5) running on port 443. I have created a Twiml app in Twilio to route incoming calls to my webrtc client. My JS file:
$(document).ready(function() {
$.post("/token/generate", function(data) {
Twilio.Device.setup(data.token);
});
});
/* Callback for when Twilio Client initiates a new connection */
Twilio.Device.connect(function (connection) {
//In call...
});
/* Callback for when Twilio Client receives a new incoming call */
Twilio.Device.incoming(function(connection) {
connection.accept(function() {
//In call...
});
answerButton.click(function() {
connection.accept();
});
});
/* End a call */
function hangUp() {
Twilio.Device.disconnectAll();
}
When I load the page for first time, I can receive the incoming call without any errors. But when I call again without reloading the page there is an error:
ERROR: ICE negotiation with Twilio failed. Call will terminate.
When I answer the second call, chrome console shows this error:
Uncaught TypeError: Cannot read property 'sdp' of null at g.getSDP (twilio.min.js:103) at twilio.min.js:95
I already looked into this doc by twilio and I verified that there is no issue with firewall.
So I added code to reload the page after disconnecting a call.
Twilio.Device.disconnect(function(connection) {
// Reloading page to avoid ICE error.
location.reload();
});
I wonder if anybody knows any solution other than reloading the page?
Upvotes: 0
Views: 806
Reputation: 1789
I was using twilio client api version 1.3. I changed it to 1.4 (media.twiliocdn.com/sdk/js/client/v1.4/twilio.min.js). Now it seems to be working.
Upvotes: 0