×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Thumbs down SIP registration - '401 Unauthorized'..

    Calling All Geeks,

    SIP has been quite a stir now but i am doubtful that it is very flexible with other opensource. Well for the time being i was trying to send a SIP register request to a Registrar present in another system through WTK 2.5 emulator .I am able to send my request but i am not able to get a 200 OK response , i keep gettng '401 UNAUTHORIZED'. After analyzing my REGISTER packet that is sent via Network Monitor tool i was able to find out that the port number in the contact field is different than the source port number from where my message is being sent, according to SIP experts this is the problem.

    i am using the folliwing code to get the random port number..

    scn = (SipConnectionNotifier)Connector.open("sip:*;type=\"application/octet-stream\"");
    //----
    ctaddr = new String("sip:100@"+scn.getLocalAddress()+ ":" + scn.getLocalPort());


    the "scn.getLocalPort()" <<-- gives the port number that have been opened automatically and since i have used the shared mode to open the connection the port nuber is supposed to be taken care by the system not by the application.

    but the WTK 2.5 open a different port and the system which is running this app is opening a different port for the coonection to the SIP registrar. Now the SIP packet is coming back to port specified by the system which is further not letting a possible binding and the Authorization fails.

    i am using the following SIP packet.

    SipClientConnection scc = null;

    // Open a SipClientConnection for REGISTER targeting the
    // registrar address
    scc = (SipClientConnection) Connector.open("sip:172.16.xx.xx:5060");
    scc.initRequest("REGISTER", scnn);

    // Set necessary headers
    scc.setHeader("From", "-my ipaaddress-");

    scc.setHeader("To", "-my ipaddress-");
    scc.setHeader("Contact", "Registrar IP address");
    scc.send();



    --------

    Since i need only one port to which i have to register (and unlike the System port and emulator port confusion). I tried the whole application on NOKIA E65 but now this application is giving me an error saying. --> RuntimeException: Initialization of the request failed. Error code :-6


    If after going thru the whole scenario you are not able to understand something or u want details in something.please send a replyi'll elaborate the question..

    Many Thanks

  2. #2
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Post Re: SIP registration - '401 Unauthorized'..

    Hello All,

    Well i was onto the problem for quite sometime now. the piece of code was pretty perfect so cudnt get what the problem is, but then after much research work i cud find out a few things that might help all the developers who are stuck into it (i knw there are a few..)

    there are various issues still unsolved and i am on it.

    1.> Aserisk server if running in unix system does not gives a sipclientConnection's getStatuCode(), It is still returning '0' to me.. on the other hand if i connect my application with Asterix windows i.e. AsteriskWin32 PBX (freely downloadable) it returns be the correct status code.

    2.> If the users that is registered in the Asterisk server has the "Secret" attribute specified..try removing it and then test . If u want it there then you have to set the corect credentials by using
    scc.setCredentials("username","password","realm");

    am still not able to figure out what do i have to put in "realm".


    ..

    Hope to get some responses .. and research
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    116

    Re: SIP registration - '401 Unauthorized'..

    Quote Originally Posted by Abhishek_karmakar View Post
    Hope to get some responses .. and research
    Hello Avishek have you already done your registration?
    i stuck in this position for few months.but i am able to do registration with some other sip server. like: ondo(brekeke)and Teksip. and also solve the 401 problem.

    I think some sip server follow different rule(not RFC 3261) thats why we dont get any response. i am trying to register my code with Cordiap and Axon sip server and getting no response.

    am still not able to figure out what do i have to put in "realm".
    what about this line?

    Opu

  4. #4
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Re: SIP registration - '401 Unauthorized'..

    Hello Apus,
    I am able to register and see the status on the emulator pretty efficiently.Your are correct on the fact that the problem is different SIP servers. It is working fine with the Windows version of Asterisk.It is efficient till it is about sending messages and sending voice one by one i.e push to talk. But it is not possible with J2ME (becuase of the KVM) it limits us to interact with the hardware. So a VOIP client is not possible with J2ME..

    take care ..

    Abhishek
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

  5. #5
    Registered User
    Join Date
    Jun 2008
    Posts
    2

    Post Re: SIP registration - '401 Unauthorized'..

    Hi - did you manage to resolve the "Initialization of the request failed. Error code :-6" error? I have the same problem running on both a Nokia N95 and E51. The exception is occurring on the line
    regObj.initRequest("REGISTER",scn);
    It works ok on the emulator (S60 3rd ed fp1)

    SipConnectionNotifier scn = (SipConnectionNotifier)
    Connector.open( "sip:*;type=\"application/test\"" );
    SipClientConnection regObj = null;
    regObj =(SipClientConnection)
    Connector.open("sip:192.168.1.101:5060");
    regObj.initRequest("REGISTER",scn);
    ...

  6. #6
    Registered User
    Join Date
    Aug 2008
    Posts
    5

    Re: SIP registration - '401 Unauthorized'..

    401 is just what it says "Unauthorized". You will have
    to re-issue your REGISTER with proper credentials. The realm
    is a fancy word for the security domain, authorization area or
    whatever you may call it. Have a look at the SIP trace to see
    how it is used. Yes you will need to calc the MD5 digest required
    to answer the challenge.

    -- Sent

    REGISTER sip:t28.net SIP/2.0
    Via: SIP/2.0/UDP 10.0.0.10:5086;branch=z9hG4bK-azw0uuow2h5q
    From: "8111000" <sip:8111000@t28.net>;tag=ctder1wfv3
    To: "8111000" <sip:8111000@t28.net>
    Call-ID: 68c69c48d007-hkzr8tvkarws@000413FFFFFF
    CSeq: 1 REGISTER
    Max-Forwards: 70
    Contact: <sip:8111000@10.0.0.10:5086;line=ojn9itpa>"
    User-Agent: Soft/5.3
    Expires: 600
    Content-Length: 0


    -- Received

    SIP/2.0 401 Unauthorized
    Via: SIP/2.0/UDP 10.0.0.10:5086;branch=z9hG4bK-azw0uuow2h5q
    From: "8111000" <sip:8111000@t28.net>;tag=ctder1wfv3
    To: "8111000" <sip:8111000@t28.net>;tag=b98f1230ac1a7949bf499aa7f9ea7038.e23e
    Call-ID: 68c69c48d007-hkzr8tvkarws@000413FFFFFF
    CSeq: 1 REGISTER
    Expires: 600
    Min-Expires: 240
    WWW-Authenticate: Digest realm="t28.net", nonce="489cc708489cc6fe88e33c821eae18c1de1123f3ecd73084"
    Server: Sip EXpress router (2.1.0-dev21-tcp (i386/linux))
    Content-Length: 0


    -- Sent

    REGISTER sip:t28.net SIP/2.0
    Via: SIP/2.0/UDP 10.0.0.10:5086;branch=z9hG4bK-0shzk8qfd509
    From: "8111000" <sip:8111000@t28.net>;tag=ctder1wfv3
    To: "8111000" <sip:8111000@t28.net>
    Call-ID: 68c69c48d007-hkzr8tvkarws@000413FFFFFF
    CSeq: 2 REGISTER
    Max-Forwards: 70
    Contact: <sip:8111000@10.0.0.10:5086;line=ojn9itpa>"
    User-Agent: Soft/5.3
    Authorization: Digest username="8111000",realm="t28.net",nonce="489cc708489cc6fe88e33c821eae18c1de1123f3ecd73084",uri="sip:t28.net",response="c704cc1d9950e0baaf81cae96a754209",algorithm=md5
    Expires: 600
    Content-Length: 0

    -- Received

    SIP/2.0 200 OK
    Via: SIP/2.0/UDP 10.0.0.10:5086;branch=z9hG4bK-0shzk8qfd509
    From: "8111000" <sip:8111000@t28.net>;tag=ctder1wfv3
    To: "8111000" <sip:8111000@t28.net>;tag=b98f1230ac1a7949bf499aa7f9ea7038.be4a
    Call-ID: 68c69c48d007-hkzr8tvkarws@000413FFFFFF
    CSeq: 2 REGISTER
    Expires: 600
    Min-Expires: 240
    Contact: <sip:8111000@10.0.0.10:5086;line=ojn9itpa>
    Server: Sip EXpress router (2.1.0-dev21-tcp (i386/linux))
    Content-Length: 0


    good luck.

  7. #7
    Regular Contributor
    Join Date
    May 2007
    Posts
    77

    Re: SIP registration - '401 Unauthorized'..

    Hi,

    I am devoloping a SIP client in J2ME. If I use the emuletor of the JSR 180 RI the application work fine, but If I use the emuletor of the S60 3rd FP1 or the mobile phone (Nokia N95) I get the error:

    initialization of the request failed. Error Code -6.

    I get this error in the method:

    scc.initRequest("REGISTER",scn);

    Have you solve this problem?

    In the API says that this method can throw two SipException: INVALID_STATE and INVALID_OPERATION. The error -6 is INVALID_OPERATION:

    SipException - INVALID_OPERATION if the method argument is one of {BYE, NOTIFY, PRACK, UPDATE}

    But the method argument that I use is "REGISTER", that is allowed. Then, Why I get this error?

    Thanks in advance.

  8. #8
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Re: SIP registration - '401 Unauthorized'..

    Hi Dimaar,
    I think the API is unavailable in S60 3rd FP1.

    I tried doing the same thing using Symbian C++ on a E65 and it was working.

    What type of Application are u trying to make using SIP. Are u only implementing data transfer like text or are u planning to implement voice transmission.

    I found Symbian c++ more promising . There are examples also which are shipped with the SDK and they will help you a great deal

    All the best.

    Abhishek karmakar
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

  9. #9
    Regular Contributor
    Join Date
    May 2007
    Posts
    77

    Re: SIP registration - '401 Unauthorized'..

    Hi, thanks for your reply.

    I am developing an application to transfer video, but, now I only do the register, I don't want send data yet.

    I have the same application in Symbian, I want that the client works in Symbian and J2ME.

    The code in Symbian works well in the emuletor of the SKD S60 3rd FP1 and in the N95. I have this error only in J2ME (but it works well if I use the emuletor of the JSR 180 RI).

    There are some way to install the JSR 180 RI in the N95, for use it instead the JSR 180 that is installed by default?

    P.D: The exception that I get in J2ME isn't a SipException, is a RuntimeException, and I don't found information about it. The SipException is explained in the API.

    How can I solve the Exception:

    RuntimeException: initialization of the request failed. Error Code -6.

    in the initRequest("REGISTER",null);

    Thanks in advance

  10. #10
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Re: SIP registration - '401 Unauthorized'..

    hey

    There are some way to install the JSR 180 RI in the N95, for use it instead the JSR 180 that is installed by default?
    JSR 180 (SIP API) is already there in your phone so i dont think that u need to install it again.

    I was able to do my registration using Symbian c++ but was not able to do it using J2ME. Also i did not get much help. It always works fine in the emulator but not on a real device using J2ME.
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

  11. #11
    Regular Contributor
    Join Date
    May 2007
    Posts
    77

    Re: SIP registration - '401 Unauthorized'..

    Hi,

    I am testing my client in the Nokia N61, only S60 3rd, not 3rd FP1.

    In this mobile I don't get the error with code -6 in the initRequest, but I get an error when I want to send the message. This error is:

    error occurred in the sending a sip request/response. Error code: -20008.

    I found information about this error and I found that this error means that the connections is not active. I found this information in this page:

    http://library.forum.nokia.com/index...1DFC0825C.html

    Why I get this error? My code is:

    SipConnectionNotifier scn;
    scn=(SipConnectionNotifier) Connector.open("sip:*;type=\"application/xjava-source\"");
    if(scn != null) {
    connected=true;
    port=scn.getLocalPort();
    // resolve Contact address from SipConnectionNotifier ino
    ctaddr = new String("sip:bob@"+scn.getLocalAddress()+":"+port);
    }

    if(connected){
    try {
    SipClientConnection scc = null;
    // Open a SipClientConnection for REGISTER targeting the
    // registrar address
    scc = (SipClientConnection) Connector.open(registrar.getString());
    scc.initRequest("REGISTER", scn);
    // Set necessary headers
    scc.setHeader("Route","<"+REG_ADD+";lr>");
    scc.setHeader("From", useraddr.getString());
    scc.setHeader("To", useraddr.getString());
    scc.setHeader("Contact", "<"+contact.getString()+">;expires=3600");
    scc.addHeader("User-agent",USER_AGENT);

    // Send it out
    System.out.println("Envia el mensaje");
    scc.send();
    ...

    The method getLocalAddress of SipConnectionNotifier return the value 'localhost', not an IP. Why? How can I get an IP?

    Thanks in advance.

  12. #12
    Registered User
    Join Date
    Jul 2008
    Posts
    7

    Re: SIP registration - '401 Unauthorized'..

    How do u do a publish request with sip for j2me I haven't seen any examples but have tried:




    try {
    // open listener in application specific port 5080
    // scn = (SipConnectionNotifier) Connector.open("sip:5070");

    // build the contact URI
    contact =
    new String("sip:albacel@***.***.**.**:5070" /* + scn.getLocalAddress()+":"+scn.getLocalPort()*/);

    // open client connection to the SIP registrar in this case "host.com"
    scc = (SipClientConnection) Connector.open("sip:albacel@***.***.**.**");
    // initialize REGISTER with appropriate headers
    scc.initRequest("PUBLISH", scn);
    scc.setHeader("From", "sip:albacel@***.***.**.**");
    scc.setHeader("To", "sip:albacel@***.***.**.**");
    scc.setHeader("Content-Type", "application/pidf+xml");
    scc.setHeader("Event", "presence");
    scc.setHeader("Expires", "1000");
    scc.setHeader("Contact", contact);

    scc.setHeader("Content-Length", Integer.toString(message.length()));

    System.out.println("SET PUBLISHING HEADER");
    OutputStream os = scc.openContentOutputStream();
    os.write(message.getBytes());

    os.close();
    System.out.println("HERE");
    // scc.send();
    System.out.println("PUBLISH REQUEST SENT");

    boolean handled = false;
    int scode = 0;

    while(!handled) {
    SipHeader sh;
    // wait max 30 secs for response
    scc.receive(30000);
    System.out.println("PUBLISHING REPONSE RECIEVED");
    scode = scc.getStatusCode();
    scc.toString();
    switch(scode)
    {
    case 423:
    System.out.println("423 PUBLISHING ERROR - Interval too brief");
    break;

    case 412:

    System.out.println("412 PUBLISHING ERROR - Interval too brief");
    break;

    case 200:
    // handle OK response
    System.out.println("200 PUBLISHING GOOD");
    handled = true;
    break;
    default:
    // handle other responses
    System.out.println("CODE: " + scode + " " + scc.getReasonPhrase() );
    handled = true;
    }
    }
    scc.close();
    } catch(Exception ex) {
    // handle Exceptions
    }



    On the server I get:


    06:47:40,781 INFO [SipResourceAdaptor] Received Request:
    PUBLISH sip:albacel@***.***.**.**:5060 SIP/2.0
    Call-ID: 72eb7303d8a67cb8a06fbb27630cee1d@146.231.88.38
    CSeq: 1 PUBLISH
    Via: SIP/2.0/UDP ***.***.**.**:5070;branch=z9hG4bK5439631f506bb74221afe26a306608
    98
    Max-Forwards: 70
    From: <sip:albacel@***.***.**.**>;tag=1892409154
    To: <sip:albacel@***.***.**.**>
    Event: presence
    Expires: 1000
    Contact: <sip:albacel@***.***.**.**:5070>
    Content-Type: application/pidf+xml
    Content-Length: 668

    <?xml version='1.0' encoding='UTF-8'?><presence xmlns='urn:ietfarams:xml:nsi
    df' xmlns:dm='urn:ietfarams:xml:nsidf:data-model' xmlns:rpid='urn:ietfarams:xml:nsidf:rpid' xmlns:c='urn:ietfaram
    s:xml:nsidf:cipid' entity='sip:albacel@***.***.**.**'><tuple id='t54bc0589'><s
    tatus><basic>open</basic></status><note>'onlin
    e'</note></tuple></presence>
    06:47:40,796 INFO [PublicationControlSbb] publication for resource sip:albacel@
    146.231.88.38:5060 on event package presence not authorized


    so it's giving me a 403 forbidden response.. Please help

  13. #13
    Registered User
    Join Date
    May 2013
    Posts
    1

    Re: SIP registration - '401 Unauthorized'..

    Hi,
    I'm facing those days a problem with sipp registration.In fact,I'm trying to register to the proxy server.
    So ,I wrote this script:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE scenario SYSTEM "sipp.dtd">

    <!-- This program is free software; you can redistribute it and/or -->
    <!-- modify it under the terms of the GNU General Public License as -->
    <!-- published by the Free Software Foundation; either version 2 of the -->
    <!-- License, or (at your option) any later version. -->
    <!-- -->
    <!-- This program is distributed in the hope that it will be useful, -->
    <!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
    <!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
    <!-- GNU General Public License for more details. -->
    <!-- -->
    <!-- You should have received a copy of the GNU General Public License -->
    <!-- along with this program; if not, write to the -->
    <!-- Free Software Foundation, Inc., -->
    <!-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -->
    <!-- -->
    <!-- Sipp default 'branchc' scenario. -->
    <!-- -->

    <scenario name="branch_client">
    <send retrans="500">
    <![CDATA[


    REGISTER sip:31399300.orange.tn SIP/2.0
    Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
    From: sipp <sip:ndi-31399300@31399300.orange.tn:[local_port]>;tag=[pid]SIPpTag00[call_number]
    To: sut <sip:[service]@[remote_ip]:[remote_port]>
    Call-ID: [call_id]
    Cseq: 1 REGISTER
    contact: sip:sipp@[local_ip]:[local_port]
    Content-length: 0
    EXpires: 1000
    ]]>
    </send>

    <recv response="401" rtd="true" auth="true" next="1" >
    </recv>

    <label id="1"/>
    <send retrans="500">
    <![CDATA[

    REGISTER sip:31399300.orange.tn SIP/2.0
    Authorization: Digest username="ndi-31399300@31399300.orange.tn",password="uXqIyrDp4Pef" ,realm="orange.net.tn",opaque="opaqueData",qop="auth",algorithm=MD5
    Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
    From: sipp <sip:ndi-31399300@31399300.orange.tn:[local_port]>;tag=[pid]SIPpTag00[call_number]
    To: sut <sip:[service]@[remote_ip]:[remote_port]>
    Call-ID: [call_id]
    Cseq: 2 REGISTER
    contact: sip:sipp@[local_ip]:[local_port]
    Content-length: 0
    EXpires: 1000


    ]]>
    </send>


    <!-- simple case - just jump over a line -->
    <recv response="200" rtd="true" >
    </recv>


    </scenario>

    the messages exchanged are:

    UDP message sent (334 bytes):

    REGISTER sip:31399300.orange.tn SIP/2.0
    Via: SIP/2.0/UDP 10.4.73.18:5060;branch=z9hG4bK-2505-1-0
    From: sipp <sip:ndi-31399300@31399300.orange.tn:5060>;tag=2505SIPpTag001
    To: sut <sip:ndi-31399300@10.4.72.18:5060>
    Call-ID: 1-2505@10.4.73.18
    Cseq: 1 REGISTER
    contact: sip:sipp@10.4.73.18:5060
    Content-length: 0
    EXpires: 1000


    ----------------------------------------------- 2013-05-16 08:45:12:392.368
    UDP message received [446] bytes :

    SIP/2.0 401 Authentication required
    Via: SIP/2.0/UDP 10.4.73.18:5060;branch=z9hG4bK-2505-1-0
    From: sipp <sip:ndi-31399300@31399300.orange.tn:5060>;tag=2505SIPpTag001
    To: sut <sip:ndi-31399300@10.4.72.18:5060>;tag=F904BE72
    Call-ID: 1-2505@10.4.73.18
    Cseq: 1 REGISTER
    WWW-Authenticate: Digest realm="orange.net.tn",nonce="FCEF8B79525519260D8C",opaque="opaqueData",qop="auth",algorithm=MD5
    Server: CommuniGatePro/5.3.15
    Content-Length: 0


    ----------------------------------------------- 2013-05-16 08:45:12:392.762
    UDP message sent (492 bytes):

    REGISTER sip:31399300.orange.tn SIP/2.0
    Authorization: Digest username="ndi-31399300@31399300.orange.tn",password="uXqIyrDp4Pef" ,realm="orange.net.tn",opaque="opaqueData",qop="auth",algorithm=MD5
    Via: SIP/2.0/UDP 10.4.73.18:5060;branch=z9hG4bK-2505-1-2
    From: sipp <sip:ndi-31399300@31399300.orange.tn:5060>;tag=2505SIPpTag001
    To: sut <sip:ndi-31399300@10.4.72.18:5060>
    Call-ID: 1-2505@10.4.73.18
    Cseq: 2 REGISTER
    contact: sip:sipp@10.4.73.18:5060
    Content-length: 0
    EXpires: 1000


    ----------------------------------------------- 2013-05-16 08:45:12:397.315
    UDP message received [447] bytes :

    SIP/2.0 401 illegal DIGEST AUTH data
    Via: SIP/2.0/UDP 10.4.73.18:5060;branch=z9hG4bK-2505-1-2
    From: sipp <sip:ndi-31399300@31399300.orange.tn:5060>;tag=2505SIPpTag001
    To: sut <sip:ndi-31399300@10.4.72.18:5060>;tag=A3E3BFFB
    Call-ID: 1-2505@10.4.73.18
    Cseq: 2 REGISTER
    WWW-Authenticate: Digest realm="orange.net.tn",nonce="FCEF8B79525519260D8C",opaque="opaqueData",qop="auth",algorithm=MD5
    Server: CommuniGatePro/5.3.15
    Content-Length: 0


    The problem is with 401 illegal DIGEST AUTH data .It started when I added Authorization: Digest username="ndi-31399300@31399300.orange.tn",password="uXqIyrDp4Pef" ,realm="orange.net.tn",opaque="opaqueData",qop="auth",algorithm=MD5.
    So , I think that the problem is in this header.
    How ,should I extract the information from the server message to put it in the client header?
    Please ,I really need your help.

Similar Threads

  1. Replies: 31
    Last Post: 2008-12-26, 11:45
  2. SIP Registration error
    By gamma8 in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2006-11-29, 09:31
  3. SIP registration
    By map123 in forum Symbian
    Replies: 0
    Last Post: 2006-09-09, 12:41
  4. SIP registration
    By map123 in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2006-09-09, 12:37
  5. SIP with 401 Unauthorized
    By y0010280 in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2005-09-29, 13:38

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×