2
votes

we want to create SIP application on Android 2.3.3 and have some issues with android.sip stack (default sip stack). Our mobile app sends register sip packet, but 1.) by default OpenIMS core responds 400 Bad request P-Visited-Network-ID Header missing 2.) in the case that we set port number to 4060 -PCSCF /builder.setPort(4060)/ OpenIMS core sends this request from 4060 to 4060 (same port, same IP, same CSCF, same packet) and this is cykling until OpenIMS core send respond to mobile app - 504 Server Time-out. We also tried SipDemo, CSipSimple and we had same problems. When we tried Monster Communicator or IMSDroid, then it works!

There is one difference between working and problematic applications - working apps send register packet also with Authorization field.

Part of the code:

public SipManager mSipManager = null; 
public SipProfile mSipProfile = null;
SipProfile.Builder builder = new SipProfile.Builder(username, domain);
builder.setPassword(password);
builder.setDisplayName(username);
builder.setProfileName(username + "@" + domain);
port = Integer.parseInt(4060);
builder.setProtocol(protocol);
mSipProfile = builder.build();
...
try { mSipManager.open(mSipProfile);} catch (SipException e) { ...}
try {
        mSipManager.register(mSipProfile, 30, new SipRegistrationListener(){
        public void onRegistering(String localProfileUri) {
        }
        public void onRegistrationDone(String localProfileUri, long expiryTime) {
        }
        public void onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage) {
        }
        });
    } catch (SipException e) {

.... }

How to give authorization field to register packet in classic SIP stack?

We also tried J-SIP but it display error: Conversion to dalvik format failed with error 1.

Every answer would be very appreciated.

1

1 Answers

0
votes

Your problem is not related to missing Authorization header.

Registration is done in the following matter:

  1. the client send Register request without "Authorization" header.

  2. server response with 401 response code which includes an header named "WWW-Authnticate", that header hold parameters as realm, opaque, qop and hashing algorithm type.

  3. using these parameters with the username and passord an Authorication header is generated automatically by SIP stacks. and a second Register request is sent which includes the "Authorication" header.

  4. the if the request is send in the correct manner the server return 200 OK response code which means that you are now registered.

Your problem is something else, you don't even get to step 3 (Authorization step), you fail in step 1, for your initial Register request you receive 400 Bad Request response code - which almost always mean that you have a syntax error in your request.