FreeSWITCH 拨号方案检查最终用户是否注册了 WebRTC 到 SIP
FreeSWITCH dialplan to check if enduser is registered for WebRTC to SIP
我正在尝试使用 FreesSWITCH with the Mizu WebRTC to SIP client。
如果被叫用户注册到 FreesSWITCH,那么呼叫应该被路由到用户。否则呼叫应路由到出站 SIP 服务器。
问题是我无法从 FreesSWITCH 拨号方案中找出用户当前是否已注册。我在默认拨号方案中有以下内容:
<!-- If the user doesn't exist, forward to outbound SIP -->
<extension name="check_user">
<condition field="${user_exists(id ${destination_number} $${domain})}" expression="false">
<action application="bridge" data="sofia/gateway/asterisk/${destination_number}"/>
</condition>
</extension>
<!-- If the user is registered, forward the call to them -->
<extension name="check_user_registered">
<condition field="${sofia_contact(profile/${destination_number}@$${domain})}" expression="(.+)">
<action application="bridge" data="" />
</condition>
</extension>
<!-- Otherwise forward to outbound SIP -->
<extension name="outbound">
<condition field="destination_number" expression="^.*$">
<action application="bridge" data="sofia/gateway/asterisk/${destination_number}"/>
</condition>
</extension>
然而"check_user_registered"规则似乎通过了,即使用户实际上没有从Webphone注册,所以FreesSWITCH会去发送呼叫给用户,但后来发现它不是已注册且呼叫失败。 (我认为 WebRTC 在这里无关紧要,这对于 SIP 到 SIP 呼叫也是一样的)。这是相关的日志:
Dialplan: sofia/internal/2233@81.12.74.77 Regex (PASS) [check_user_registered] ${sofia_contact(profile/${destination_number}@rtc.mizu-voip.com)}(error/user_not_registered) =~ /(.+)/ break=on-false
Dialplan: sofia/internal/2233@81.12.74.77 Action bridge(error/user_not_registered)
Freeswitch hangup with 480 Temporarily Unavailable / USER_NOT_REGISTERED
你知道从 FreesSWITCH 拨号规则查询用户注册状态的可靠方法吗?
sofia_contact
returns 字符串 error/user_not_registered
如果用户未注册。在您的情况下,您根据 .+
正则表达式检查返回值。当然,错误字符串也会匹配。
你需要一个匹配^error
的条件,然后定义动作和反动作。
使用sofia_contact
可以知道被叫人是否注册。
例如:
sofia_contact 1001
return这个给我
sofia/internal/sip:1001@myip_address:52573;实例=a1b0a9cfddc6a8c3;传输=TCP
sofia_contact 1002
error/user_not_registered
另一种选择是将注册用户存储到数据库中,并使用 odbc 查询获取结果并进行比较。(这将是一个绝妙的主意)
我正在尝试使用 FreesSWITCH with the Mizu WebRTC to SIP client。 如果被叫用户注册到 FreesSWITCH,那么呼叫应该被路由到用户。否则呼叫应路由到出站 SIP 服务器。
问题是我无法从 FreesSWITCH 拨号方案中找出用户当前是否已注册。我在默认拨号方案中有以下内容:
<!-- If the user doesn't exist, forward to outbound SIP -->
<extension name="check_user">
<condition field="${user_exists(id ${destination_number} $${domain})}" expression="false">
<action application="bridge" data="sofia/gateway/asterisk/${destination_number}"/>
</condition>
</extension>
<!-- If the user is registered, forward the call to them -->
<extension name="check_user_registered">
<condition field="${sofia_contact(profile/${destination_number}@$${domain})}" expression="(.+)">
<action application="bridge" data="" />
</condition>
</extension>
<!-- Otherwise forward to outbound SIP -->
<extension name="outbound">
<condition field="destination_number" expression="^.*$">
<action application="bridge" data="sofia/gateway/asterisk/${destination_number}"/>
</condition>
</extension>
然而"check_user_registered"规则似乎通过了,即使用户实际上没有从Webphone注册,所以FreesSWITCH会去发送呼叫给用户,但后来发现它不是已注册且呼叫失败。 (我认为 WebRTC 在这里无关紧要,这对于 SIP 到 SIP 呼叫也是一样的)。这是相关的日志:
Dialplan: sofia/internal/2233@81.12.74.77 Regex (PASS) [check_user_registered] ${sofia_contact(profile/${destination_number}@rtc.mizu-voip.com)}(error/user_not_registered) =~ /(.+)/ break=on-false
Dialplan: sofia/internal/2233@81.12.74.77 Action bridge(error/user_not_registered)
Freeswitch hangup with 480 Temporarily Unavailable / USER_NOT_REGISTERED
你知道从 FreesSWITCH 拨号规则查询用户注册状态的可靠方法吗?
sofia_contact
returns 字符串 error/user_not_registered
如果用户未注册。在您的情况下,您根据 .+
正则表达式检查返回值。当然,错误字符串也会匹配。
你需要一个匹配^error
的条件,然后定义动作和反动作。
使用sofia_contact
可以知道被叫人是否注册。
例如:
sofia_contact 1001
return这个给我 sofia/internal/sip:1001@myip_address:52573;实例=a1b0a9cfddc6a8c3;传输=TCPsofia_contact 1002
error/user_not_registered
另一种选择是将注册用户存储到数据库中,并使用 odbc 查询获取结果并进行比较。(这将是一个绝妙的主意)