Reputation: 61
Using Twilio.js to record a call using webRTC. Works fine except at the 10 minute mark (exact!) the call hangs up. Max record time on TwiML is set to 7200secs.
The browser's console shows:
[Twilio.PeerConnection] signalingState is "stable"
twilio.js:1843 [Twilio.PeerConnection] iceConnection State is "checking"
twilio.js:1843 [Twilio.PeerConnection] iceConnection State is "connected"
twilio.js:1843 [Twilio.PeerConnection] iceConnection State is "completed"
[After 10 minutes...]
twilio.js:1843 [Connection] Received HANGUP from gateway
twilio.js:1843 [Connection] Disconnecting...
Chrome://webrtc-internals dump is useless:
{
"time": "11/28/2016, 4:35:48 PM",
"type": "iceConnectionStateChange",
"value": "ICEConnectionStateCompleted"
},
{
"time": "11/28/2016, 4:45:51 PM",
"type": "stop",
"value": ""
},
Breaking in the twilio.js library I see that something sends a websocket message with payload: {"payload":{"callsid":"CA18974349269fb9f24977185c5deaa62c"},"type":"hangup","version":""}
, which clearly causes the client to hang up the call.
Any ideas of why this may happen? It happens from both desktop and mobile browsers.
Upvotes: 2
Views: 1911
Reputation: 61
Turns out Twilio is cutting off webRTC calls after 600 seconds. Not exactly sure why but I am guessing it has something to do --stale-nonce param for Turn Servers which coincidentally have a 600 sec timeout. Maybe?
EDIT with fix.
Eventually Twilio responded to our ticket and provided a workaround to enable WEBRTC 10+ min recording. IMHO it's quite hacky, but it works.
When the caller joins, pump an outbound API call into the conference with a that plays a silent mp3, either a really long one or a looped short one. This outbound leg is necessary to start the conference, and the silent mp3 will send RTP bidirectionally. Another rather similiar is to have the client dial into like this:
<Response>
<Dial record="true" action="record_action">
<Conference waitUrl="url_to_nearly_silent_audio_file">record</Conference>
</Dial>
</Response>
You will need to manufacture a low volume WAV file for a loop in waitURL, in case a completely silent WAV file doesn't generate RTP packets.
https://www.twilio.com/docs/api/twiml/conference
Upvotes: 1
Reputation: 7777
I know I am stating the obvious, but your answer is here:
[After 10 minutes...]
twilio.js:1843 [Connection] Received HANGUP from gateway
This may be because something in Twilio is timing out. Do you need to send a heartbeat to keep it alive?
Upvotes: 0