我正在創建一個實現SipListener接口的類,以接收來自JAIN-SIP堆棧(對於Android設備)的事件。爲了測試它,我將2個設備連接到一個OpenSIP,並嘗試調用另一個設備。我使用第三方客戶端沒有問題。JAIN-SIP RINGING響應從未發送
除了一個奇怪的問題,一切似乎都與我的基本實現一起工作。當我收到processRequest中的INVITE請求時,我創建了一個RINGING響應,然後是一個OK響應。問題在於(根據tcpdump)RINGING響應永遠不會到達服務器。收到INVITE數據包之後,設備發送一個TRYING數據包(我沒有在我的代碼中執行此操作,因此它必須是JAIN-SIP的一部分),然後使用OK數據包進行跟蹤。我跟着各種各樣的例子,他們都似乎表明這些方針的東西:與64.xxx作爲OpenSIPs IP和10
INVITE sip:[email protected]:5060 SIP/2.0
Call-ID: [email protected]
CSeq: 20 INVITE
From: "Caller" <sip:[email protected]:5060>;tag=12345
To: "Callee" <sip:[email protected]:5060>
Via: SIP/2.0/UDP 10.x.x.10:5060;branch=z9hG4bKe45cd7919b5177a806ec1a9238b841f9393739
Max-Forwards: 70
Contact: "4321" <sip:[email protected]:5060>
Content-Length: 0
:
//This function gets called from processRequest
//Some initialization code removed to keep this short
private void processInvite(RequestEvent requestEvent)
{
ServerTransaction serverTransaction = requestEvent.getServerTransaction();
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
Request request = requestEvent.getRequest();
//Create RINGING response
Response response = m_messageFactory.createResponse(Response.RINGING,
request);
//Add a contact header
Address contactAddress = m_addressFactory
.createAddress(m_username + " <sip:" + getLocalIpAddress() + ":" + m_sipPort + ">");
ContactHeader contactHeader = m_headerFactory.createContactHeader(contactAddress);
response.addHeader(contactHeader);
if (serverTransaction == null)
{
serverTransaction = sipProvider.getNewServerTransaction(request);
}
//Send RINGING response
//This never makes it to the server
serverTransaction.sendResponse(response);
//Create OK response
Response okResponse = m_messageFactory.createResponse(Response.OK, request);
ToHeader toHeader = (ToHeader) okResponse.getHeader(ToHeader.NAME);
toHeader.setTag("4321");
okResponse.addHeader(contactHeader);
//Send OK Response
//This makes it to the server
serverTransaction.sendResponse(okResponse);
}
作爲參考,INVITE頭這個樣子。 xx10是UAC的IP。
我錯過了一個標題或者不正確地設置了RINGING包嗎?任何幫助是極大的讚賞!
我最終使用了一個不同的庫,但這是有道理的,所以我將它標記爲正確的答案。謝謝! – Andrey 2011-07-09 15:08:39