为啥有时 Jain Sip 在收到再见时会返回“481 Call Leg/Transaction does Not Exist”?
Posted
技术标签:
【中文标题】为啥有时 Jain Sip 在收到再见时会返回“481 Call Leg/Transaction does Not Exist”?【英文标题】:Why sometimes Jain Sip return "481 Call Leg/Transaction Does Not Exist" on received bye?为什么有时 Jain Sip 在收到再见时会返回“481 Call Leg/Transaction does Not Exist”? 【发布时间】:2020-10-20 11:27:55 【问题描述】:使用 jain sip 创建 sip 代理应用程序。 客户端 A -> 代理应用程序 -> 客户端 B 万一 A 呼叫 B:A 可以挂断,但是当 B 发送 BYE 时,Jain Sip 将 481 呼叫支路返回给 B。 当呼叫在几秒钟内结束时,它可以 BYE 成功。 但是如果通话在几分钟内结束,当 B 发送 BYE 时,Jain sip 返回 481 通话支路。 而调用方客户端 A 总是 BYE 成功。 已经检查了 call-id、request uri、from、to 标记。还是不知道。
这是日志
<message
from="192.168.101.217:5217"
to="192.168.100.45:5062"
time="1593501306804"
isSender="false"
transactionId="z9hg4bk474906270"
callId="1024711825"
firstLine="INVITE sip:14@192.168.100.45:5062 SIP/2.0"
>
<![CDATA[INVITE sip:14@192.168.100.45:5062 SIP/2.0
Via: SIP/2.0/UDP 192.168.101.217:5217;rport=5217;branch=z9hG4bK474906270;received=192.168.101.217
From: <sip:217@192.168.100.45:5062>;tag=966553558
To: <sip:14@192.168.100.45:5062>
Call-ID: 1024711825
CSeq: 20 INVITE
Contact: <sip:217@192.168.101.217:5217>
Content-Type: application/sdp
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,NOTIFY,MESSAGE,SUBSCRIBE,INFO
Max-Forwards: 70
User-Agent: eXosip/3.1.0
Subject: Call conversation
Expires: 120
Content-Length: 405
]]>
</message>
<message
from="192.168.100.45:5062"
to="192.168.101.14:5014"
time="1593501306864"
isSender="true"
transactionId="z9hg4bk-3137-6aaa9fa3786b6b7fb08d9bdbbf9256c5"
callId="1024711825"
firstLine="INVITE sip:14@192.168.100.45:5062 SIP/2.0"
>
<![CDATA[INVITE sip:14@192.168.100.45:5062 SIP/2.0
Via: SIP/2.0/UDP 192.168.100.45:5062;branch=z9hG4bK-3137-6aaa9fa3786b6b7fb08d9bdbbf9256c5,SIP/2.0/UDP 192.168.101.217:5217;rport=5217;branch=z9hG4bK474906270;received=192.168.101.217
From: "217" <sip:217@192.168.100.45:5062>;tag=966553558
To: <sip:14@192.168.100.45:5062>
Call-ID: 1024711825
CSeq: 20 INVITE
Contact: <sip:217@192.168.101.217:5217>
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,NOTIFY,MESSAGE,SUBSCRIBE,INFO
Max-Forwards: 70
User-Agent: eXosip/3.1.0
Subject: Call conversation
Expires: 120
Content-Type: application/sdp
Route: "14" <sip:14@192.168.101.14:5014;lr>
Record-Route: "TERRA_PROXY_SERVER" <sip:TERRA_PROXY_SERVER@192.168.100.45:5062;lr>
Content-Length: 403
]]>
</message>
<message
from="192.168.101.14:5014"
to="192.168.100.45:5062"
time="1593501307050"
isSender="false"
transactionId="z9hg4bk-3137-6aaa9fa3786b6b7fb08d9bdbbf9256c5"
callId="1024711825"
firstLine="SIP/2.0 200 OK"
>
<![CDATA[SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.100.45:5062;branch=z9hG4bK-3137-6aaa9fa3786b6b7fb08d9bdbbf9256c5,SIP/2.0/UDP 192.168.101.217:5217;rport=5217;branch=z9hG4bK474906270;received=192.168.101.217
Record-Route: "TERRA_PROXY_SERVER" <sip:TERRA_PROXY_SERVER@192.168.100.45:5062;lr>
From: "217" <sip:217@192.168.100.45:5062>;tag=966553558
To: <sip:14@192.168.100.45:5062>;tag=113355942
Call-ID: 1024711825
CSeq: 20 INVITE
Contact: <sip:14@192.168.101.14:5014>
Content-Type: application/sdp
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,NOTIFY,MESSAGE,SUBSCRIBE,INFO
User-Agent: eXosip/3.1.0
Content-Length: 200
]]>
</message>
<message
from="192.168.101.14:5014"
to="192.168.100.45:5062"
time="1593501307051"
isSender="false"
transactionId="z9hg4bk-3137-6aaa9fa3786b6b7fb08d9bdbbf9256c5"
callId="1024711825"
firstLine="SIP/2.0 200 OK"
>
<![CDATA[SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.100.45:5062;branch=z9hG4bK-3137-6aaa9fa3786b6b7fb08d9bdbbf9256c5,SIP/2.0/UDP 192.168.101.217:5217;rport=5217;branch=z9hG4bK474906270;received=192.168.101.217
Record-Route: "TERRA_PROXY_SERVER" <sip:TERRA_PROXY_SERVER@192.168.100.45:5062;lr>
From: "217" <sip:217@192.168.100.45:5062>;tag=966553558
To: <sip:14@192.168.100.45:5062>;tag=113355942
Call-ID: 1024711825
CSeq: 20 INVITE
Contact: <sip:14@192.168.101.14:5014>
Content-Type: application/sdp
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,NOTIFY,MESSAGE,SUBSCRIBE,INFO
User-Agent: eXosip/3.1.0
Content-Length: 200
]]>
</message>
<message
from="192.168.100.45:5062"
to="192.168.101.217:5217"
time="1593501307054"
isSender="true"
transactionId="z9hg4bk474906270"
callId="1024711825"
firstLine="SIP/2.0 200 OK"
>
<![CDATA[SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.101.217:5217;rport=5217;branch=z9hG4bK474906270;received=192.168.101.217
Record-Route: "TERRA_PROXY_SERVER" <sip:TERRA_PROXY_SERVER@192.168.100.45:5062;lr>
From: "217" <sip:217@192.168.100.45:5062>;tag=966553558
To: <sip:14@192.168.100.45:5062>;tag=113355942
Call-ID: 1024711825
CSeq: 20 INVITE
Contact: <sip:14@192.168.101.14:5014>
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,NOTIFY,MESSAGE,SUBSCRIBE,INFO
User-Agent: eXosip/3.1.0
Content-Type: application/sdp
Content-Length: 200
]]>
</message>
<message
from="192.168.101.217:5217"
to="192.168.100.45:5062"
time="1593501307348"
isSender="false"
transactionId="z9hg4bk1089380003"
callId="1024711825"
firstLine="ACK sip:14@192.168.100.45:5062 SIP/2.0"
>
<![CDATA[ACK sip:14@192.168.100.45:5062 SIP/2.0
Via: SIP/2.0/UDP 192.168.101.217:5217;rport=5217;branch=z9hG4bK1089380003;received=192.168.101.217
Route: "TERRA_PROXY_SERVER" <sip:TERRA_PROXY_SERVER@192.168.100.45:5062;lr>
From: "217" <sip:217@192.168.100.45:5062>;tag=966553558
To: <sip:14@192.168.100.45:5062>;tag=113355942
Call-ID: 1024711825
CSeq: 20 ACK
Contact: <sip:217@192.168.101.217:5217>
Max-Forwards: 70
User-Agent: eXosip/3.1.0
Content-Length: 0
]]>
</message>
<message
from="192.168.100.45:5062"
to="192.168.101.14:5014"
time="1593501307353"
isSender="true"
transactionId="966553558-1024711825-20-ack-192.168.100.45-50623137"
callId="1024711825"
firstLine="ACK sip:14@192.168.100.45:5062 SIP/2.0"
>
<![CDATA[ACK sip:14@192.168.100.45:5062 SIP/2.0
Via: SIP/2.0/UDP 192.168.100.45:5062;branch=966553558-1024711825-20-ack-192.168.100.45-50623137,SIP/2.0/UDP 192.168.101.217:5217;rport=5217;branch=z9hG4bK1089380003;received=192.168.101.217
Route: "14" <sip:14@192.168.101.14:5014;lr>,"TERRA_PROXY_SERVER" <sip:TERRA_PROXY_SERVER@192.168.100.45:5062;lr>
From: "217" <sip:217@192.168.100.45:5062>;tag=966553558
To: <sip:14@192.168.100.45:5062>;tag=113355942
Call-ID: 1024711825
CSeq: 20 ACK
Contact: <sip:217@192.168.101.217:5217>
Max-Forwards: 70
User-Agent: eXosip/3.1.0
Content-Length: 0
]]>
</message>
<message
from="192.168.101.14:5014"
to="192.168.100.45:5062"
time="1593501381766"
isSender="false"
transactionId="z9hg4bk106975397"
callId="1024711825"
firstLine="BYE sip:217@192.168.100.45:5062 SIP/2.0"
>
<![CDATA[BYE sip:217@192.168.100.45:5062 SIP/2.0
Via: SIP/2.0/UDP 192.168.101.14:5014;rport=5014;branch=z9hG4bK106975397;received=192.168.101.14
Route: "TERRA_PROXY_SERVER" <sip:TERRA_PROXY_SERVER@192.168.100.45:5062;lr>
From: <sip:14@192.168.100.45:5062>;tag=113355942
To: "217" <sip:217@192.168.100.45:5062>;tag=966553558
Call-ID: 1024711825
CSeq: 2 BYE
Contact: <sip:14@192.168.101.14:5014>
Max-Forwards: 70
User-Agent: eXosip/3.1.0
Content-Length: 0
]]>
</message>
<message
from="192.168.100.45:5062"
to="192.168.101.14:5014"
time="1593501381771"
isSender="true"
transactionId="z9hg4bk106975397"
callId="1024711825"
firstLine="SIP/2.0 481 Call leg/Transaction does not exist"
>
<![CDATA[SIP/2.0 481 Call leg/Transaction does not exist
CSeq: 2 BYE
Call-ID: 1024711825
From: <sip:14@192.168.100.45:5062>;tag=113355942
To: "217" <sip:217@192.168.100.45:5062>;tag=966553558
Via: SIP/2.0/UDP 192.168.101.14:5014;rport=5014;branch=z9hG4bK106975397;received=192.168.101.14
Content-Length: 0
]]>
</message>
<message
from="192.168.101.217:5217"
to="192.168.100.45:5062"
time="1593501389132"
isSender="false"
transactionId="z9hg4bk550352336"
callId="1024711825"
firstLine="BYE sip:14@192.168.100.45:5062 SIP/2.0"
>
<![CDATA[BYE sip:14@192.168.100.45:5062 SIP/2.0
Via: SIP/2.0/UDP 192.168.101.217:5217;rport=5217;branch=z9hG4bK550352336;received=192.168.101.217
Route: "TERRA_PROXY_SERVER" <sip:TERRA_PROXY_SERVER@192.168.100.45:5062;lr>
From: "217" <sip:217@192.168.100.45:5062>;tag=966553558
To: <sip:14@192.168.100.45:5062>;tag=113355942
Call-ID: 1024711825
CSeq: 21 BYE
Contact: <sip:217@192.168.101.217:5217>
Max-Forwards: 70
User-Agent: eXosip/3.1.0
Content-Length: 0
]]>
</message>
<message
from="192.168.100.45:5062"
to="192.168.101.217:5217"
time="1593501389136"
isSender="true"
transactionId="z9hg4bk550352336"
callId="1024711825"
firstLine="SIP/2.0 200 OK"
>
<![CDATA[SIP/2.0 200 OK
CSeq: 21 BYE
Call-ID: 1024711825
From: "217" <sip:217@192.168.100.45:5062>;tag=966553558
To: <sip:14@192.168.100.45:5062>;tag=113355942
Via: SIP/2.0/UDP 192.168.101.217:5217;rport=5217;branch=z9hG4bK550352336;received=192.168.101.217
Contact: "217" <sip:217@192.168.101.217>;expires=60
Expires: 60
Content-Length: 0
]]>
</message>
<message
from="192.168.100.45:5062"
to="192.168.101.14:5014"
time="1593501389137"
isSender="true"
transactionId="966553558-1024711825-21-bye-192.168.100.45-50623137"
callId="1024711825"
firstLine="BYE sip:14@192.168.101.14:5014 SIP/2.0"
>
<![CDATA[BYE sip:14@192.168.101.14:5014 SIP/2.0
Via: SIP/2.0/UDP 192.168.100.45:5062;branch=966553558-1024711825-21-bye-192.168.100.45-50623137,SIP/2.0/UDP 192.168.101.217:5217;rport=5217;branch=z9hG4bK550352336;received=192.168.101.217
From: "217" <sip:217@192.168.100.45:5062>;tag=966553558
To: <sip:14@192.168.100.45:5062>;tag=113355942
Call-ID: 1024711825
CSeq: 21 BYE
Contact: <sip:217@192.168.101.217:5217>
Max-Forwards: 70
User-Agent: eXosip/3.1.0
Content-Length: 0
]]>
</message>
<message
from="192.168.101.14:5014"
to="192.168.100.45:5062"
time="1593501389154"
isSender="false"
transactionId="966553558-1024711825-21-bye-192.168.100.45-50623137"
callId="1024711825"
firstLine="SIP/2.0 481 Call Leg/Transaction Does Not Exist"
>
<![CDATA[SIP/2.0 481 Call Leg/Transaction Does Not Exist
Via: SIP/2.0/UDP 192.168.100.45:5062;branch=966553558-1024711825-21-bye-192.168.100.45-50623137,SIP/2.0/UDP 192.168.101.217:5217;rport=5217;branch=z9hG4bK550352336;received=192.168.101.217
From: "217" <sip:217@192.168.100.45:5062>;tag=966553558
To: <sip:14@192.168.100.45:5062>;tag=113355942
Call-ID: 1024711825
CSeq: 21 BYE
User-Agent: eXosip/3.1.0
Content-Length: 0
]]>
</message>
<message
from="192.168.101.14:5014"
to="192.168.100.45:5062"
time="1593501389155"
isSender="false"
transactionId="966553558-1024711825-21-bye-192.168.100.45-50623137"
callId="1024711825"
firstLine="SIP/2.0 481 Call Leg/Transaction Does Not Exist"
>
<![CDATA[SIP/2.0 481 Call Leg/Transaction Does Not Exist
Via: SIP/2.0/UDP 192.168.100.45:5062;branch=966553558-1024711825-21-bye-192.168.100.45-50623137,SIP/2.0/UDP 192.168.101.217:5217;rport=5217;branch=z9hG4bK550352336;received=192.168.101.217
From: "217" <sip:217@192.168.100.45:5062>;tag=966553558
To: <sip:14@192.168.100.45:5062>;tag=113355942
Call-ID: 1024711825
CSeq: 21 BYE
User-Agent: eXosip/3.1.0
Content-Length: 0
]]>
</message>
getServerTransaction 代码 当自动对话关闭时。 st 为 null,但 getNewServerTransaction 时仍然异常。
public static ServerTransaction getServerTransaction(RequestEvent eventObject)
ServerTransaction st = eventObject.getServerTransaction();
if (st != null)
return st;
SipProvider sipProvider = (SipProvider) eventObject.getSource();
if (sipProvider == null)
log.debug("getServerTransaction fail. SipProvider is null.");
return null;
try
st = sipProvider.getNewServerTransaction(eventObject.getRequest());
catch (SipException se)
log.debug("getServerTransaction fail.", se);
return st;
【问题讨论】:
【参考方案1】:如果您从 jsip 收到 481,这表明您在收到 BYE 时正在尝试查找一个对话框,并且此时它可能不存在。当 jsip 是代理时,您不应该有任何 jsip 对话框。
jsip 中的代理应用程序不应该依赖 jsip 对话框,并且必须维护自己的对话框状态(或者对于无状态代理不应该)。代理应始终以无状态对话框模式实现,这基本上意味着避免创建任何对话框。你可以在这里看到一个一般的例子https://github.com/usnistgov/jsip/blob/master/src/examples/forked/invite/Proxy.java
如果您已经这样做了,请发布一些代码和调试级别的日志。
【讨论】:
谢谢。我没有任何耆那教的对话。我找到了 jain sip 触发器 processDialogTerminated(DialogTerminatedEvent dte)。这可能是问题所在。我不知道它为什么会触发 DialogTerminatedEvent,事件源是 gov.nist.javax.sip.SipProviderImpl 。我在那里没有找到任何 BYE/CANCEL 请求。但在那之后,客户端A仍然可以BYE成功。 可能是您启用了自动对话模式,请确保自动对话已关闭 properties.setProperty("javax.sip.AUTOMATIC_DIALOG_SUPPORT", "off"); 是的。自动对话已开启。但是当我将其更改为关闭时,它无法使用 SipProvider.getNewServerTransaction(Request req) 。 它可以使用它只需要注意重传,在此处查看代理示例github.com/usnistgov/jsip/blob/master/src/examples/forked/… 你的意思是检查ServerTransaction吗?我添加了我的 getServerTransaction 代码。当自动对话关闭时。当 ServerTransaction 为空时,它仍然会抛出异常。我用它向另一个客户端发送 ACK。【参考方案2】:您需要仔细查看 Route、Record-Route 和 Contact 标头。
初始错误出现在代理上的 User-Agent 收到的第一个 ACK 中。
ACK sip:14@192.168.100.45:5062 SIP/2.0
上面的request-uri应该是200 Ok的Contact。
ACK sip:14@192.168.101.14:5014 SIP/2.0
我建议您修复所有 Contact、Record-Route、Route,然后确保您处理 ACK 和 BYE 在代理模式下:即,您需要使用 request-uri 和 Route 转发它们,而不是回答它们。
【讨论】:
我尝试更改 request-uri,但它仍然返回 481 call leg。以上是关于为啥有时 Jain Sip 在收到再见时会返回“481 Call Leg/Transaction does Not Exist”?的主要内容,如果未能解决你的问题,请参考以下文章
Android 在使用 Jain-SIP 库创建 SipStack 时出错