我尝试使用request.createResponse(200)在Invite请求后使用Sip Servlet发送200 OK响应。
问题是Contact标头没有"用户名"部分。 为什么会这样?
protected void doInvite(SipServletRequest arg0) throws ServletException, IOException {
SipServletResponse respRinging = arg0.createResponse(180);
respRinging.send();
SipServletResponse respOk = arg0.createResponse(200);
String sdpData = "v=0\r\n" +
"o=- 2 2 IN IP4 192.168.50.18\r\n" +
"s=Testing V1.0\r\n" +
"c=IN IP4 192.168.50.18\r\n" +
"t=0 0\r\n" +
"m=audio 63364 RTP/AVP 18 101\r\n" +
"a=fmtp:18 annexb=yes\r\n" +
"a=fmtp:101 0-15\r\n" +
"a=rtpmap:18 G729/8000\r\n" +
"a=rtpmap:101 telephone-event/8000\r\n" +
"a=sendrecv\r\n";
byte[] contents = sdpData.getBytes();
respOk.setContent(contents, arg0.getContentType());
respOk.send();
}
%dMES%22=SIP/2.0 200 OK
Call-ID: ZDE4MzY3NzAzNjRlN2UwZDBmMGZlNDA1MTNlZWJiOWE.
CSeq: 1 INVITE
From: 6000 <sip:6000@192.168.50.18>;tag=d765eb39
To: 2451 <sip:2451@192.168.50.18>;tag=9020141091761795_local.1330939329531_17_16
Via: SIP/2.0/UDP 192.168.50.201:57332;branch=z9hG4bK-d8754z-cc352300a144627e-1---d8754z-;rport=57332;received=192.168.50.201
Content-Type: application/sdp
Content-Length: 221
Contact: sip:IP-HOST:5060;transport=udp
我希望联系人URI为sip:2451@IP-HOST:5060;transport=udp
答案 0 :(得分:0)
我想jain-sip会自动填充Contact URI。这是一个完全有效的联系人URI - 不需要用户名。
如果您需要指定特定的URI,是否尝试过respOk.addHeader("Contact", "My sip:special@uri:5060")
?