SIP代理认证失败
我正在开发一个 SIP 用户代理应用程序,该应用程序连接到 Asterisk 服务器并尝试进行拨出呼叫。我正在使用 JAIN SIP API 的 NIST 实现。
应用程序首先成功注册自身。然后,当应用程序将 INVITE 请求传输到 X-Lite SIP 软电话时,Asterisk 将使用 407(需要代理身份验证)响应进行响应。响应包含 Proxy-Authenticate 标头。我的应用程序再次发送 INVITE,但这次带有代理授权标头,Asterisk 会响应 488(此处不可接受)。
以下是 SIP 对话(“>>”表示传出消息;“<<”表示传入消息):
<代码>>>注册 sip:10.0.84.30:5060 SIP/2.0
呼叫 ID:[电子邮件受保护]
Cseq:1个寄存器
来自:;tag=0vmZig
至:
通过:SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK493cd4b63090dc9a8027931937b737c9353835 最大前锋:70
联系方式:
过期时间:300
内容长度:0
<< SIP/2.0 100 尝试
通过:SIP/2.0/UDP 10.0.85.3:5060;分支=z9hG4bK493cd4b63090dc9a8027931937b737c9353835;收到=10.0.85.3
来自:
至:
呼叫 ID:[电子邮件受保护]
Cseq:1个寄存器
用户代理:Asterisk PBX (switchvox)
允许:邀请、确认、取消、选项、再见、参考、订阅、通知
联系方式:[电子邮件受保护]>
内容长度:0
<< SIP/2.0 401 未经授权
通过:SIP/2.0/UDP 10.0.85.3:5060;分支=z9hG4bK493cd4b63090dc9a8027931937b737c9353835;收到=10.0.85.3
来自:
至:
呼叫 ID:[电子邮件受保护]
Cseq:1个寄存器
用户代理:Asterisk PBX (switchvox)
允许:邀请、确认、取消、选项、再见、参考、订阅、通知
联系方式:[电子邮件受保护]>
WWW-Authenticate:摘要领域=“星号”,随机数=“27ca4a51”
内容长度:0
<代码>>>注册 sip:10.0.84.30:5060 SIP/2.0
Cseq: 2 寄存器
来自:;tag=0vmZig
至:
通过:SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKe339b4ed9edc5d75379673b6dec7fc42353835 最大前锋:70
联系方式:
过期时间:300
授权:摘要用户名=“301”,领域=“星号”,随机数=“27ca4a51”,响应=“cfdcdff7ddee99d10c3099e88ffb73af”,算法= MD5,uri=“sip:10.0.84.30:5060”,nc=00000001
呼叫 ID:[电子邮件受保护]
内容长度:0
<< SIP/2.0 100 尝试
通过:SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKe339b4ed9edc5d75379673b6dec7fc42353835;received=10.0.85.3
来自:
至:
呼叫 ID:[电子邮件受保护]
Cseq: 2 寄存器
用户代理:Asterisk PBX (switchvox)
允许:邀请、确认、取消、选项、再见、参考、订阅、通知
联系方式:[电子邮件受保护]>
内容长度:0
<< SIP/2.0 200 好的
通过:SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKe339b4ed9edc5d75379673b6dec7fc42353835;received=10.0.85.3
来自:
至:
呼叫 ID:[电子邮件受保护]
Cseq: 2 寄存器
用户代理:Asterisk PBX (switchvox)
允许:邀请、确认、取消、选项、再见、参考、订阅、通知
过期时间:300
联系方式:
日期:2011 年 5 月 3 日,星期二 09:37:45 GMT
内容长度:0
<代码>>>邀请 sip:302@asterisk SIP/2.0
呼叫 ID:[电子邮件受保护]
Cseq:3 邀请
来自:;tag=sJSeLA
至:
通过:SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK6704cd9554c0c8e5bc94bc42b606147a353835 最大前锋:70
联系方式:
路由:
内容类型:application/sdp
内容长度:106<代码>v=0
o=- 3513403599 3513403599 IP4 10.0.85.3
s=-
c=IP4 10.0.85.3
t=0 0
m=音频 40000 RTP/AVP 3
<< SIP/2.0 407 需要代理身份验证
通过:SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK6704cd9554c0c8e5bc94bc42b606147a353835;received=10.0.85.3
来自:
至:
呼叫 ID: [电子邮件受保护]
Cseq:3 邀请
用户代理:Asterisk PBX (switchvox)
允许:邀请、确认、取消、选项、再见、参考、订阅、通知
联系人:[电子邮件受保护]>
代理验证:摘要领域 =“asterisk”,nonce =“55deefb6”
内容长度:0
<代码>>>邀请 sip:302@asterisk SIP/2.0
CSeq:4 邀请
来自:;tag=sJSeLA
至:
通过:SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK6e3501c0973664fcd7a17affddd23572353835 最大前锋:70
联系方式:
路由:
内容类型:application/sdp
代理授权:摘要用户名=“301”,领域=“星号”,随机数=“55deefb6”,响应=“47e2c7abe625e4a183726e29c035d7e0”,算法= MD5,uri=“sip:302@asterisk”,nc=00000001
呼叫 ID:[电子邮件受保护]
内容长度:106<代码>v=0
o=- 3513403599 3513403599 IP4 10.0.85.3
s=-
c=IN IP4 10.0.85.3
t=0 0
m=音频 40000 RTP/AVP 3
<< SIP/2.0 488 此处不可接受
通过:SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK6e3501c0973664fcd7a17affddd23572353835;received=10.0.85.3
来自:
至:
呼叫 ID:[电子邮件受保护]
CSeq:4 邀请
用户代理:Asterisk PBX (switchvox)
允许:邀请、确认、取消、选项、再见、参考、订阅、通知
联系方式:[电子邮件受保护]>
Content-Length: 0
我在这里做错了什么,导致了 488 响应?
I'm developing a SIP user agent application that connects to an Asterisk server and tries to do an outgoing call. I'm using the NIST implementation of the JAIN SIP API.
The application first registers itself successfully. Then, when the application transmits an INVITE request to an X-Lite SIP soft phone, Asterisk responds with a 407 (Proxy Authentication Required) response. The response contains a Proxy-Authenticate header. My application sends an INVITE again, but this time with the Proxy-Authorization header, upon which Asterisk responds with 488 (Not acceptable here).
Here follows the SIP conversation ('>>' indicates outgoing messages; '<<' indicates incoming messages):
>> REGISTER sip:10.0.84.30:5060 SIP/2.0
Call-ID: [email protected]
CSeq: 1 REGISTER
From: <sip:301@asterisk>;tag=0vmZig
To: <sip:301@asterisk>
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK493cd4b63090dc9a8027931937b737c9353835
Max-Forwards: 70
Contact: <sip:10.0.85.3:5060>
Expires: 300
Content-Length: 0
<< SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK493cd4b63090dc9a8027931937b737c9353835;received=10.0.85.3
From: <sip:301@asterisk>;tag=0vmZig
To: <sip:301@asterisk>
Call-ID: [email protected]
CSeq: 1 REGISTER
User-Agent: Asterisk PBX (switchvox)
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
Contact: <sip:[email protected]>
Content-Length: 0
<< SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK493cd4b63090dc9a8027931937b737c9353835;received=10.0.85.3
From: <sip:301@asterisk>;tag=0vmZig
To: <sip:301@asterisk>;tag=as4d134cc6
Call-ID: [email protected]
CSeq: 1 REGISTER
User-Agent: Asterisk PBX (switchvox)
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
Contact: <sip:[email protected]>
WWW-Authenticate: Digest realm="asterisk",nonce="27ca4a51"
Content-Length:0
>> REGISTER sip:10.0.84.30:5060 SIP/2.0
CSeq: 2 REGISTER
From: <sip:301@asterisk>;tag=0vmZig
To: <sip:301@asterisk>
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKe339b4ed9edc5d75379673b6dec7fc42353835
Max-Forwards: 70
Contact: <sip:10.0.85.3:5060>
Expires: 300
Authorization: Digest username="301",realm="asterisk",nonce="27ca4a51",response="cfdcdff7ddee99d10c3099e88ffb73af",algorithm=MD5,uri="sip:10.0.84.30:5060",nc=00000001
Call-ID: [email protected]
Content-Length: 0
<< SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKe339b4ed9edc5d75379673b6dec7fc42353835;received=10.0.85.3
From: <sip:301@asterisk>;tag=0vmZig
To: <sip:301@asterisk>
Call-ID: [email protected]
CSeq: 2 REGISTER
User-Agent: Asterisk PBX (switchvox)
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
Contact: <sip:[email protected]>
Content-Length: 0
<< SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKe339b4ed9edc5d75379673b6dec7fc42353835;received=10.0.85.3
From: <sip:301@asterisk>;tag=0vmZig
To: <sip:301@asterisk>;tag=as4d134cc6
Call-ID: [email protected]
CSeq: 2 REGISTER
User-Agent: Asterisk PBX (switchvox)
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
Expires: 300
Contact: <sip:10.0.85.3:5060>;expires=300
Date: Tue, 03 May 2011 09:37:45 GMT
Content-Length: 0
>> INVITE sip:302@asterisk SIP/2.0
Call-ID: [email protected]
CSeq: 3 INVITE
From: <sip:301@asterisk>;tag=sJSeLA
To: <sip:302@asterisk>
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK6704cd9554c0c8e5bc94bc42b606147a353835
Max-Forwards: 70
Contact: <sip:10.0.85.3:5060>
Route: <sip:10.0.84.30:5060;lr>
Content-Type: application/sdp
Content-Length: 106
v=0
o=- 3513403599 3513403599 IN IP4 10.0.85.3
s=-
c=IN IP4 10.0.85.3
t=0 0
m=audio 40000 RTP/AVP 3
<< SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK6704cd9554c0c8e5bc94bc42b606147a353835;received=10.0.85.3
From: <sip:301@asterisk>;tag=sJSeLA
To: <sip:302@asterisk>;tag=as7358e1b8
Call-ID: [email protected]
CSeq: 3 INVITE
User-Agent: Asterisk PBX (switchvox)
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
Contact: <sip:[email protected]>
Proxy-Authenticate: Digest realm="asterisk",nonce="55deefb6"
Content-Length: 0
>> INVITE sip:302@asterisk SIP/2.0
CSeq: 4 INVITE
From: <sip:301@asterisk>;tag=sJSeLA
To: <sip:302@asterisk>
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK6e3501c0973664fcd7a17affddd23572353835
Max-Forwards: 70
Contact: <sip:10.0.85.3:5060>
Route: <sip:10.0.84.30:5060;lr>
Content-Type: application/sdp
Proxy-Authorization: Digest username="301",realm="asterisk",nonce="55deefb6",response="47e2c7abe625e4a183726e29c035d7e0",algorithm=MD5,uri="sip:302@asterisk",nc=00000001
Call-ID: [email protected]
Content-Length: 106
v=0
o=- 3513403599 3513403599 IN IP4 10.0.85.3
s=-
c=IN IP4 10.0.85.3
t=0 0
m=audio 40000 RTP/AVP 3
<< SIP/2.0 488 Not acceptable here
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK6e3501c0973664fcd7a17affddd23572353835;received=10.0.85.3
From: <sip:301@asterisk>;tag=sJSeLA
To: <sip:302@asterisk>;tag=as7358e1b8
Call-ID: [email protected]
CSeq: 4 INVITE
User-Agent: Asterisk PBX (switchvox)
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
Contact: <sip:[email protected]>
Content-Length: 0
What am I doing wrong here, causing the 488 response?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
488 响应几乎可以肯定是因为 SIP 客户端和 Asterisk 服务器之间的编解码器不匹配。在您的 SIP 跟踪中,您的客户端请求使用 GSM 编解码器进行呼叫,我的猜测是您的 Asterisk 服务器配置为不允许 GSM。
重新配置您的 Asterisk 服务器以接受 GSM,或者尝试更改您的 SDP 以使用 ULAW 或 ALAW,因为 Asterisk 很少被配置为不接受这些。
在下面的示例中,没有更改 m= 行的末尾。 0 对应于 PCMU (ULAW),8 对应于 PCMA (ALAW)。
The 488 response is almost certainly because of a codec mismatch between your SIP client and your Asterisk server. In your SIP trace your client is requesting the call use the GSM codec and my guess is your Asterisk server is configured to not allow GSM.
Either re-configure your Asterisk server to accept GSM or try changing your SDP to use ULAW or ALAW as it's pretty rare for Asterisk to be configured not to accept those.
In the below sample not the change to the end of the m= line. 0 corresponds to PCMU (ULAW) and 8 corresponds to PCMA (ALAW).