我有一个托管在DigitalOcean上的Asterisk服务器,使用Twilio的中继服务,在恰好120秒后通话中断。值得注意的是,直接连接的软电话不会掉线。端口5060在防火墙上应有的状态是打开的。
有一个自动值班人员接听电话并将其传递给脚本,但这在不使用sip网络电话挂断电话的情况下可以完全正常工作。我给Twilio发了电子邮件,他们说问题可能是因为Asterisk没有发送180振铃,我可以理解这是因为我没有拨打电话,而是立即应答。
真正切断电话的是什么?
sip.conf
[twilio]
type=peer
secret=secret
username=user
host=host.domain.com
dtmfmode=rfc2833
canreinvite=no
disallow=all
allow=ulaw
insecure=port,invite
fromuser=+15555555555
fromdomain=from-domain.domain.com
context=incoming
deny=0.0.0.0/0
permit=x.x.x.x/32
permit=x.x.x.x/32
permit=x.x.x.x/32
permit=x.x.x.x/32
extensions.ael上下文
+15555555555 => {
Answer();
EAGI(tincan.js);
AGI(agi://127.0.0.1/saytext,"Goodbye.");
Hangup();
}
开始呼叫数据包捕获
21 4.827782 (Them) (Us) SIP/SDP 1341 Request: INVITE sip:[email protected] |
22 4.831487 (Us) (Them) SIP 819 Status: 100 Trying |
23 4.833205 (Us) (Them) SIP/SDP 1112 Status: 200 OK |
通话结束包捕获
16066 124.821787 (Them) (Us) SIP 650 Request: BYE sip:[email protected]:5060 |
16067 124.822736 (Us) (Them( SIP 700 Status: 200 OK |
Twilio报告了此问题,因为我们的服务器没有在较长时间内发送任何RTP数据,因此连接超时。我正在使用的Dialplan运行了一个自定义的EAGI脚本,该脚本将在电话中无限期地记录此人。该过程在另一端超时。
我非常骇人的解决方案如下:
反复发送10秒钟的静默时间可防止服务器超时。我可以想象发送1秒钟的静音会完成同样的事情并节省带宽,但是您的里程可能会有所不同。
我的Node.js脚本函数代替了WAIT FOR DIGIT或RECORD FILE函数:
/**
* Loop playing silence until interrupted
* @param done =function( timedout ) Callback when the silence has been interrupted
* @param maxRecordTime Length of time to be able to record max. Leave blank for no timeout.
* @param stopTime Timestamp when the recording should be stopped
*/
Index.prototype.loopSilenceUntilInterrupted = function( done, maxRecordTime, stopTime ) {
var that = this;
// Set the stopTime?
if( maxRecordTime!==undefined && stopTime===undefined )
stopTime = Date.now()+maxRecordTime;
this.context.getOption( "silence/10", "#", 10, function( error, response ) {
if( response.result==35 )
done( false ); // We have been diggery
else if( stopTime!==undefined && Date.now()>=stopTime )
done( true ); // We have timed out!
else
that.loopSilenceUntilInterrupted( done, maxRecordTime, stopTime ); // Do it again
},
0 ); // No cooldown
};
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句