RDP, doack, and b2buaservlet

Source: Internet
Author: User

Because the musicserver cannot be found, the SDP messages that require the musicserver, such as call wait/call persistence, are directly written to the sipservletmessage on the server, but what headers are required in this SDP? Refer to examples.

Private void addsdp (sipservletmessage re, string Uri, string call_id) {<br/> try {<br/> string name = new string (""); <br/> string callid = new string (""); <br/> int start = Uri. indexof (":"); <br/> int end = Uri. indexof ("@"); <br/> name = Uri. substring (START, end ). trim (); <br/> Start = 0; <br/> end = call_id.indexof ("@"); <br/> callid = call_id.substring (START, end ). trim (); <br/> string reinvitesdp = "V = 0/R/N" + "O = % 1 $ S % 2 $ s in ip4 test010.ericsson.com/r/n" <br/> + "s = "session SDP/R/N "+" c = in ip4 music.server.ericsson.com/r/n "+" t = 3034423619 0/R/N "<br/> +" m = audio 3456 RTP/AVP 0 /R/N "+" A = rtpmap: 0 pc mu/8000/R/N "+" A = sendonly/R/N "; <br/> reinvitesdp = string. format (reinvitesdp, name, callid); <br/> log ("proxyservlet: addsdp: SDP message is/N" + reinvitesdp); <br/> re. setcontent (reinvitesdp, "application/SDP"); <br/>} catch (exception e) {<br/> E. printstacktrace (); <br/>}< br/>} 

 

Doack (), there is a bug here, that is, Ack can be sent to the client sometimes, sometimes it won't work, it takes a lot of time to check, sometimes it can be restarted on the server, but sometimes it won't be successful once after restart... later, I checked the signaling packets on the server and found that the router header of each ack was quite long ~ So I focused on this. This ack was automatically generated by testagent, but it was definitely to copy the information in 200ok to create this request. So I looked at 200ok again and found that its recordrouter header was too long, then, check the invite. On the client of Alice, the router header is okay, but the router on Bob's side is very long ~ Finally, I suddenly remembered that in doinvite (), there was a sentence:

Proxy. setrecordroute (true );

All subsequent messages can be sent to the server first, commented out, and handled !!!

Nnd, after half a day, the problem lies in doinvite ().

 

B2buaservlet, there is nothing to say... mainly deal with two doinvite () and dosuccessresponse ()

Doinvite () is also very simple, mainly because the APIS required by B2B are not very familiar... it feels strange. Finally, I copied the sample code on Sun and made some modifications.

Protected void doinvite (inclusipservletrequest) <br/> throws servletexception, ioexception {<br/> // get the Back to Back UA helper <br/> b2buahelper helper = sipservletrequest. getb2buahelper (); <br/> // create the new invite for the destinator <br/> sipservletrequest request = helper. createrequest (sipservletrequest, true, null); <br/> request. setrequesturi (sipservletrequest. getaddressheader (""). Geturi (); <br/> sipservletresponse response = request. createresponse (sipservletresponse. SC _ OK); <br/> // The route is required because we want the request to go directory to <br/> // The S-cscf. <br/> addcscfroute (request); <br/> If (sipservletrequest. getcontent ()! = NULL) {<br/> response. setcontent (sipservletrequest. getcontent (), <br/> sipservletrequest. getcontenttype (); <br/> request. setcontent (sipservletrequest. getcontent (), <br/> sipservletrequest. getcontenttype (); <br/>}< br/> response. send (); <br/> // we also need to add the p-asserted-identity header for the s-cscf to <br/> // validate our request <br/> string assertedidentity = sipservletrequest. getheader (asserted_identity_header); <br/> addassertedidentity (request, assertedidentity); <br/> // send the request <br/> request. send (); <br/>} 

 

Dosuccessresponse () is simpler...

Protected void dosuccessresponse (sipservletresponse resp) <br/> throws servletexception, ioexception {<br/> // when a 200 OK for an invite is already ed, send an ACK <br/> sipservletrequest ACK = resp. createack (); <br/> // check if pending SDP to include in ack <br/> Object content = resp. getsession (). getattribute ("SDP"); <br/> If (content! = NULL) {<br/> ack. setcontent (content, "application/SDP"); <br/>}< br/> ack. send (); <br/>} 

It's just that b2bua's function has not been further tested... theoretically feasible. Today's time is spent on proxyservlet's bug...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.