我正在尝试为移动设备编写 SIP 客户端。我使用 PJSIP for android 和 Linphone for iOS。有时,客户端会响应 481 以获取合法的 CANCEL。
我阅读了 RFC 3261 Section 9.1 并试图了解为什么客户端与对话框不匹配。但据我所知,请求 URI 匹配,Call-ID header 、包含标签的 To header 以及 Cseq 的数字部分也是如此
INVITE sip:#######@127.0.0.0 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-197747523180-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: <sip:#######@127.0.0.0>
Max-Forwards: 68
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204936 INVITE
Contact: <sip:##########@127.0.0.1>
User-Agent: Server UAS
Allow: ACK,BYE,CANCEL,INVITE,REGISTER,UPDATE,MESSAGE,INFO,OPTIONS,SUBSCRIBE,NOTIFY,REFER,COMET,PUBLISH,PING,DO
Allow-Events: presence,refer,telephone-event,keep-alive,dialog,message-summary
Supported: privacy,replaces
Accept: application/sdp,application/dtmf-relay,audio/telephone-event,message/sipfrag,text/plain,text/html
Content-Disposition: session;handling=required
Content-Type: application/sdp
Content-Length: 521
v=0
o=root 1954582096 1954582096 IN IP4 127.0.0.2
s=Sonus_UAC
c=IN IP4 127.0.0.1
t=0 0
m=audio 10852 RTP/AVP 0 9 8 18 10 3 111 5 7 110 97 101
a=rtpmap:0 PCMU/8000
a=rtpmap:9 G722/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:10 L16/8000
a=rtpmap:3 GSM/8000
a=rtpmap:111 G726-32/8000
a=rtpmap:5 DVI4/8000
a=rtpmap:7 LPC/8000
a=rtpmap:110 speex/8000
a=rtpmap:97 iLBC/8000
a=fmtp:97 mode=30
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-197747523180-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: sip:#######@127.0.0.0
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204936 INVITE
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-197747523180-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: <sip:#######@127.0.0.0>;tag=43ye8Yn
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204936 INVITE
User-Agent: belle-sip/1.6.3
Supported: replaces, outbound
CANCEL sip:#######@127.0.0.0 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-171352412518-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: <sip:#######@127.0.0.0>
Max-Forwards: 68
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204936 CANCEL
User-Agent: Server UAS
Warning: 399 127.0.0.0 "Cancel received (0x15) (4007)"
M-Stat: s:0 r:0 l:0 es:0 er:0 el:0
Content-Length: 0
BYE sip:#######@127.0.0.0 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-151544386511-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: <sip:#######@127.0.0.0>;tag=43ye8Yn
Max-Forwards: 68
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204937 BYE
User-Agent: Server UAS
Warning: 399 127.0.0.0 "Cancel received (0x15) (4007)"
M-Stat: s:0 r:0 l:0 es:0 er:0 el:0
Content-Length: 0
SIP/2.0 481 Call/transaction does not exist
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-171352412518-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: <sip:#######@127.0.0.0>;tag=K4PcWbb
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204936 CANCEL
SIP/2.0 501 Not implemented
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-151544386511-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: <sip:#######@127.0.0.0>;tag=43ye8Yn
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204937 BYE
CANCEL sip:#######@127.0.0.0 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-171352412518-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: <sip:#######@127.0.0.0>
Max-Forwards: 68
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204937 CANCEL
User-Agent: Server UAS
Warning: 399 127.0.0.0 "Cancel received (0x15) (4007)"
M-Stat: s:0 r:0 l:0 es:0 er:0 el:0
Content-Length: 0
SIP/2.0 481 Call/transaction does not exist
Via: SIP/2.0/UDP 127.0.0.1:5060;rport;branch=z9hG4bK-171352412518-702327557205
From: "WIRELESS CALLER" <sip:##########@my.sipserver.com>;tag=a410144978468667
To: <sip:#######@127.0.0.0>;tag=azviy
Call-ID: 0ce8e8201a70540029d0ec3402005633@127.0.0.2:5060-b4-3551-277
CSeq: 204937 CANCEL
出于隐私原因,我已删除识别详细信息。
最佳答案
CANCEL 请求有一项额外要求(RFC3261 第 9.1 章):
当 UAS 收到 CANCEL 请求时,它必须找到相应的 INVITE 服务器事务。 RFC3261 第 9.2 章:
匹配标准之一是 CANCEL 请求顶部 Via header 中的分支参数:它必须与创建服务器事务的 INVITE 请求中的参数相同。由于 INVITE 和 CANCEL 请求中的分支参数不同,UAS 找不到服务器事务并取消 INVITE。
关于SIP 客户端在取消时响应 481,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57191347/