[SIPForum-discussion] plz help me with sip registration
maruf syfullah
maruf.syfullah at gmail.com
Mon Nov 19 10:46:25 UTC 2007
Dear
i am trying sip registration.but response of register request can't be
captured.
i have installed sip server on my local lan.i have created a register user
with user name="maruf" and password="123".
--------sip server address is 195.194.193.7
---------my host's ip is 195.194.193.5.
i am using following very little code:
SipClientConnection scc = null;
SipConnectionNotifier scn = null;
String contact = null;
String realm=null;
String username="maruf",password="123";
try {
scn = (SipConnectionNotifier) Connector.open("sip:5080");
contact = new
String("sip:maruf@"+scn.getLocalAddress()+":"+scn.getLocalPort());
scc = (SipClientConnection) Connector.open("sip:195.194.193.7");
scc.initRequest("REGISTER", scn);
scc.setHeader("From", "sip:maruf at 195.194.193.7");
scc.setHeader("To", " sip:maruf at 195.194.193.7");
scc.setHeader("Contact", contact);
scc.send();
boolean handled = false;
int scode = 10;
while(!handled) {
SipHeader sh;
// wait max 30 secs for response
scc.receive(900);
scode = scc.getStatusCode();
switch(scode)
{
case 401:
sh = new SipHeader("WWW-Authenticate",
scc.getHeader("WWW-Authenticate"));
realm = sh.getParameter ("realm");
scc.setCredentials("maruf", "123", realm);
break;
case 407:
sh = new SipHeader("Proxy-Authenticate",
scc.getHeader("Proxy-Authenticate"));
realm = sh.getParameter("realm");
// here for example, prompt user for password for this
realm
// set credentials to initiate re-REGISTER
scc.setCredentials("maruf", "123", realm);
break;
case 200:
// handle OK response
handled = true;
break;
default:
System.out.println("default" );
// handle other responses
// handled = true;
}
}/////////////////
// scc.close();
} catch(Exception ex) {
// handle Exceptions
}
using packet sniffer i have seen that response from server comes to my host
but my program cant capture it.i have tried using netbeans and wireless
toolkit.
will u plz tell me where is the problem?
Best Regards
Maruf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sipforum.org/pipermail/discussion/attachments/20071119/5e35feb6/attachment-0002.html>
More information about the discussion
mailing list