带有授权的SIP Stack注册包

时间:2012-03-13 17:22:17

标签: android sip

我们想在Android 2.3.3上创建SIP应用程序,并且在android.sip堆栈(默认sip堆栈)方面存在一些问题。我们的移动应用程序发送注册sip数据包,但是 1.)默认情况下,OpenIMS核心响应400 Bad请求P-Visited-Network-ID Header丢失 2.)在我们将端口号设置为4060 -PCSCF /builder.setPort(4060)/的情况下,OpenIMS核心从4060到4060(相同的端口,相同的IP,相同的CSCF,相同的数据包)发送此请求,这是cykling直到OpenIMS核心发送响应移动应用程序 - 504服务器超时。 我们也试过SipDemo,CSipSimple,我们遇到了同样的问题。 当我们尝试使用Monster Communicator或IMSDroid时,它就可以了!

工作和有问题的应用程序之间存在一个区别 - 工作应用程序也会在授权字段中发送寄存器数据包。

部分代码:

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) {

....         }

如何在经典SIP堆栈中为授权字段注册数据包?

我们也尝试过J-SIP,但显示错误:转换为dalvik格式失败,错误为1。

每个答案都会非常感激。

1 个答案:

答案 0 :(得分:0)

您的问题与缺少授权标头无关。

注册在以下事项中完成:

  1. 客户端发送没有“授权”标题的注册请求。

  2. 具有401响应代码的服务器响应,其中包含名为“WWW-Authnticate”的标头,该标头将参数保存为realm,opaque,qop和散列算法类型。

  3. 将这些参数与用户名和密码一起使用,SIP堆栈会自动生成Authorication标头。并发送第二个注册请求,其中包括“Authorication”标题。

  4. 如果请求以正确的方式发送,则服务器返回200 OK响应代码,这意味着您现在已注册。
  5. 您的问题是其他问题,您甚至没有进入第3步(授权步骤),您在步骤1中失败,为您的初始注册请求收到400 Bad Request响应代码 - 这几乎总是意味着您的请求中存在语法错误。