Twilio to OnSip应用程序错误:拨号 - > Sip:SIP URI DNS无法解析或解析为非公开IP地址
问题描述:
我正在使用Twilio为我的公司构建SIP拨号解决方案,并且我收到错误“拨号 - > Sip:SIP URI DNS不解析或解析为非公共IP地址”。我在onsip上有一个试用账户来测试功能,当我打电话给这个账号时,它失败了。相关TwiML是:Twilio to OnSip应用程序错误:拨号 - > Sip:SIP URI DNS无法解析或解析为非公开IP地址
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial callerId="+15555555555">
<Sip>sip:[email protected]</Sip>
</Dial>
</Response>
至于谷歌搜索已经得到了我,我认为我可能需要我的白名单中的应用程序。我也想知道,因为我在本地主机上使用我的应用程序,这是问题,但我用ngrok,仍然收到错误。
答
这是不可能的Twilio与OnSip,因为在这个问题上制定了已知问题的互动:https://support.onsip.com/hc/en-us/articles/204599674-Twillio-and-SRV
希望这免去别人头疼。
答
使用Twilio新实现的functions可解决此问题。
像这样的东西应该work--
const dns = require('dns');
let sipUri = '[email protected]';
let protocol = 'udp';
let region = 'us2' ;
exports.handler = function(context, event, callback) {
var user = sipUri.split('@')[0];
var host = sipUri.split('@')[1];
// generate the TwiML to tell Twilio how to forward this call
let twiml = new Twilio.twiml.VoiceResponse();
const dial = twiml.dial();
dns.resolveSrv('_sip._'+protocol+'.'+host, (err, addresses) => {
var resolvedhost = addresses[0].name+':'+addresses[0].port;
dial.sip('sip:'+user+'@'+resolvedhost+';region='+region);
console.log(twiml.toString());
// return the TwiML
callback(null, twiml);
});
};
此手动将查询SRV记录的主机名,然后使用第一个结果返回。不考虑重量和优先事项。