同时注册SIP错误 [英] Sip Error while registration

查看:382
本文介绍了同时注册SIP错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的SIP电话的本地方法,这是工作的罚款,但一段时间后它给登记错误IN_PROGRESS(错误code -9)。我在SIP错误codeS搜索,但力发现任何错误$ C $这种℃。这是我的$ C $下SIP注册。请告诉我,如果任何一个有想法有关此错误,请告诉我。

 进口android.app.Activity;
进口android.app.Notification;
进口android.app.NotificationManager;
进口android.app.PendingIntent;
进口android.content.Context;
进口android.content.Intent;
进口android.content.Shared preferences;
进口android.os.Bundle;
。进口的Andr​​oid preference preferenceManager。
进口android.util.Log;
进口android.view *。
进口android.net.sip *。
进口java.text.ParseException;
/ **
 *处理所有的呼叫,接听电话,并在WalkieTalkie应用程序用户界面交互。
 * /
公共类WalkieTalkieActivity扩展活动实现View.OnTouchListener {

    公共字符串sipAddress = NULL;
    公共静态SipManager经理= NULL;
    公共静态SipProfile我= NULL;
    公共SipAudioCall呼叫= NULL;
    公共SipError code SIP code;
    公共SipException sipexeception;
    公共静态WalkieTalkieActivity walkiy;

    公共静态WalkieTalkieActivity的getInstance(){
        如果(walkiy == NULL){
            walkiy =新WalkieTalkieActivity();
        }
        返回walkiy;
    }

    @
    覆盖
    公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        。getWindow()addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        Log.e(的onCreate,的onCreate);
        initializeManager(本);
    }

    @
    覆盖
    公共无效的OnStart(){
        super.onStart();
        //当我们从preference设置活动回来,假设
        //设置已经改变,并重新登录新的验证信息。
    }

    @
    覆盖
    公共无效的onDestroy(){

        super.onDestroy();
        如果(呼!= NULL){
            call.close();
        }
        closeLocalProfile();
    }

    @
    覆盖
    保护无效onResume(){
        initializeManager(本);
        super.onResume();
    }

    公共无效initializeManager(上下文CTX){

        Log.e(inilitize,初始化经理人);

        如果(经理== NULL){
            经理= SipManager.newInstance(CTX);

        }
        initializeLocalProfile(CTX);
    }

    / **
     *日志你进入你的SIP提供商,注册该装置的位置
     *发送SIP呼叫到您的SIP地址。
     * /
    公共无效initializeLocalProfile(最终上下文CTX){
        Log.e(inilitize,初始化配置文件);
        如果(经理== NULL){

            Log.e(inilitize,回报简介);
            updateStatus(我们无法确定这个功能您的设备上,CTX);
            Log.e(无线状态,+ SipManager.isSipWifiOnly(CTX));
            返回;
        }
        共享preferences preFS = preferenceManager.getDefaultShared preferences(CTX);
        字符串username = prefs.getString(名称preF,XYZ);
        字符串域= prefs.getString(域preF,236.343.230.2);
        字符串password = prefs.getString(通preF,XYZ);

        尝试 {
            Log.e(inilitize,建筑型材);
            SipProfile.Builder建设者=新SipProfile.Builder(用户名,域);
            builder.setPassword(密码);
            我= builder.build();
            manager.open(箱);

            Log.e(alredy registered1,+ manager.isRegistered(me.getUriString()));
            尝试 {
                如果(manager.isRegistered(me.getUriString())){

                    Log.e(alredy registered2,+ manager.isRegistered(me.getUriString()));
                    updateStatus(就绪,CTX);
                    返回;
                }

            }赶上(SipException E){
                // TODO自动生成的catch块
                closeLocalProfile();
                e.printStackTrace();
            }

            manager.setRegistrationListener(me.getUriString(),新思pregistrationListener(){
                公共无效onRegistering(字符串localProfileUri){

                    Log.e(SIP restration,与SIP服务器上注册...+ me.getUriString());
                    updateStatus(注册与SIP服务器...,CTX);
                }

                公共无效onRegistrationDone(字符串localProfileUri,长expiryTime){
                    Log.e(SIP restration,准备好了);
                    updateStatus(就绪,CTX);

                }

                公共无效onRegistrationFailed(字符串localProfileUri,诠释错误code,
                    字符串的errorMessage){
                    Log.e(错误code注册管理办法,SipError code.toString(错误code)++错误code);
                    updateStatus(SipError code.toString(错误code),CTX);
                }
            });
        }赶上(ParseException的PE){
            updateStatus(连接错误,CTX);
        }赶上(SipException SE){
            updateStatus(连接错误,CTX);
        }
    }

    / **
     *关闭了您的本地配置文件,释放关联对象到内存
     *和从服务器取消注册您的设备。
     * /
    公共无效closeLocalProfile(){
        如果(经理== NULL){
            返回;
        }
        尝试 {
            如果(我!= NULL){
                manager.unregister(我来说,新思pregistrationListener(){

                    @
                    覆盖
                    公共无效onRegistrationFailed(字符串localProfileUri,诠释错误code,
                        字符串的errorMessage){
                        // TODO自动生成方法存根
                        Log.e(取消注册失败,取消注册失败);

                    }

                    @
                    覆盖
                    公共无效onRegistrationDone(字符串localProfileUri,长expiryTime){
                        // TODO自动生成方法存根
                        Log.e(注销完成,注销完成);
                    }

                    @
                    覆盖
                    公共无效onRegistering(字符串localProfileUri){
                        // TODO自动生成方法存根
                        Log.e(注销,注销);
                    }
                });
                manager.close(me.getUriString());
            }
        }赶上(例外EE){
            Log.d(WalkieTalkieActivity /的onDestroy,无法关闭本地配置文件。EE);
        }
    }

    / **
     *拨出电话。
     * /
    公共无效initiateCall(串号,最后的上下文CTX,最终的视图V){


        Log.d(号码,+编号);
        sipAddress =号;

        Log.e(发起呼叫,发起呼叫);
        尝试 {



            SipAudioCall.Listener监听器=新SipAudioCall.Listener(){@
                覆盖
                公共无效onCallBusy(SipAudioCall调用){
                    // TODO自动生成方法存根
                    Log.e(比济,比济);
                    super.onCallBusy(电话);
                }

                @
                覆盖
                公共无效onCallHeld(SipAudioCall调用){
                    // TODO自动生成方法存根
                    Log.e(保持,保持);
                    super.onCallHeld(电话);
                }

                @
                覆盖
                公共无效onCalling(SipAudioCall调用){
                    // TODO自动生成方法存根
                    Log.e(呼唤​​,呼唤);
                    super.onCalling(电话);
                }

                @
                覆盖
                公共无效调用onChanged(SipAudioCall调用){
                    // TODO自动生成方法存根
                    Log.e(改,改);
                    super.onChanged(电话);
                }

                @
                覆盖
                公共无效onerror的(SipAudioCall电话,INT错误code,
                    字符串的errorMessage){
                    // TODO自动生成方法存根

                    Log.e(调用错误,错误+ SipError code.toString(错误code)++错误code);
                    CallingScreen.fa.finish();
                    super.onError(调用,错误code,的errorMessage);
                }

                @
                覆盖
                公共无效onReadyToCall(SipAudioCall调用){
                    // TODO自动生成方法存根
                    Log.e(准备打电话,准备打电话);
                    super.onReadyToCall(电话);
                }

                @
                覆盖
                公共无效onRinging(SipAudioCall电话,SipProfile来电){
                    // TODO自动生成方法存根
                    Log.e(振铃,响铃);

                    super.onRinging(来电,来电者);
                }

                @
                覆盖
                公共无效onRingingBack(SipAudioCall调用){
                    // TODO自动生成方法存根
                    Log.e(振铃后,振铃背面);

                    super.onRingingBack(电话);
                }

                //许多客户端的与SIP栈相互作用将
                通过监听//发生。即使拨出电话,不
                //忘记设置一个侦听器,一旦建立呼叫设置的东西了。
                @
                覆盖
                公共无效onCallEstablished(SipAudioCall调用){

                    Log.e(呼叫建立,呼叫建立);
                    call.startAudio();
                    更新时间(真,CTX);
                }

                @
                覆盖
                公共无效onCallEnded(SipAudioCall调用){
                    Log.e(通话结束,通话结束);

                    更新时间(假,CTX);
                    CallingScreen.fa.finish();
                }
            };

            Log.e(参数1,+ me.getUriString());
            调用= manager.makeAudioCall(me.getUriString(),sipAddress +@ 216.245.200.2:5060,监听器,30);
        }赶上(例外五){
            e.printStackTrace();
            Log.i(试图关闭经理时出现错误。WalkieTalkieActivity / InitiateCall,E);
            如果(我!= NULL){
                尝试 {
                    closeLocalProfile();
                }赶上(例外EE){
                    ee.printStackTrace();
                    Log.i(WalkieTalkieActivity / InitiateCall
                        错误当试图关闭经理,EE);
                    ee.printStackTrace();
                }
            }
            如果(呼!= NULL){
                call.close();
            }
        }
    }


    公共无效updateStatus(最后弦乐状态,最终上下文语境){
        //做一个好公民。确保用户界面的变化UI线程着火。
        this.runOnUiThread(新的Runnable(){
            公共无效的run(){
                generateNotification(上下文,状态);

            }
        });
    }

    公共无效录入(最终布尔状态,最终的上下文语境){
        //做一个好公民。确保用户界面的变化UI线程着火。
        this.runOnUiThread(新的Runnable(){
            公共无效的run(){

                如果(状态){
                    CallingScreen.fa.calling_screen_text.setVisibility(View.GONE);
                    CallingScreen.fa.ch.setVisibility(View.VISIBLE);
                    CallingScreen.fa.ch.start();
                } 其他 {
                    CallingScreen.fa.ch.stop();
                }
            }
        });
    }


    公共无效updateStatus(SipAudioCall调用){
        字符串USENAME = call.getPeerProfile()getDisplayName()。
        如果(USENAME == NULL){
            USENAME = call.getPeerProfile()getUserName()。
        }
        // updateStatus(USENAME +@+ call.getPeerProfile()getSipDomain());
    }


    公共布尔onTouch(视图V,MotionEvent事件){
        如果(调用== NULL){
            返回false;
        }否则,如果(event.getAction()== MotionEvent.ACTION_DOWN和放大器;&安培;调用= NULL和放大器;!&安培; call.isMuted()){
            call.toggleMute();
        }否则如果(event.getAction()== MotionEvent.ACTION_UP&安培;&安培;!call.isMuted()){
            call.toggleMute();
        }
        返回false;
    }
    公共无效扬声器(布尔州){
        如果(呼!= NULL)
            call.setSpeakerMode(州);
    }

    公共无效结束呼叫(){
        如果(呼!= NULL){
            尝试 {
                call.endCall();
            }赶上(SipException SE){
                Log.d(WalkieTalkieActivity / onOptionsItemSelected
                    错误结束通话。SE);
            }
            call.close();
        }
    }

    公共静态无效generateNotification(上下文的背景下,字符串消息){
        Log.e(inilitize,生成的通知);
        INT图标= R.drawable.ic_launcher;
        时长= System.currentTimeMillis的();
        NotificationManager notificationManager =(NotificationManager)
        context.getSystemService(Context.NOTIFICATION_SERVICE);
        通知通知=新的通知(图标,邮件,时);
        字符串标题= context.getString(R.string.app_name);
        意图notificationIntent =新的意图(背景下,Splash_screen.class);
        //设置的意图,因此它不会开始一个新的活动
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
            Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent意图=
            PendingIntent.getActivity(上下文,0,notificationIntent,0);
        notification.setLatestEventInfo(背景下,标题,邮件,意图);
        notificationManager.notify(0,通知);
    }
}
 

解决方案

SIP是一个基于事务协议,这意味着,每一个谈判过程是一个交易(例如,一个基本的注册过程将意味着发送REISTER请求和接收200 OK响应)。我张贴在一个小例子,这的响应。

IN_PROGRESS错误初步表明您试图启动一个新的事务,在你的情况下,您要发送一个注册请求,当客户端已经在另一个相关的。

一个比较典型的情况是,在一个快速的注销/登录,试图在注销过程仍在运行登记(无200 OK最终响应已接收)。

对于Android的SIP实现这个错误code的主要问题是,当作为通用错误处理SIP请求时,它的使用失败的话,previous的意义就失去了意义。

因为previous问题

您需要检查的logcat,以获得更多的信息,(你会看到类似~~~~~ SipSessionGroup ::处理),但是,要处理这种最好的方式,将要共事由堆栈提供不同的听众。

该协议栈提供了两个监听器,可以让注册的错误:的思pregistrationListener SipSession.Listener 。双方提供<一href="https://developer.android.com/reference/android/net/sip/Si$p$pgistrationListener.html#onRegistrationFailed%28java.lang.String,%20int,%20java.lang.String%29"相对=nofollow> onRegistrationFailed 回调,但后来之一,还提供了<一个href="https://developer.android.com/reference/android/net/sip/SipSession.Listener.html#onRegistrationTimeout%28android.net.sip.SipSession%29"相对=nofollow> onRegistrationTimeout ,这可以说是相当有帮助的。其实,你已经使用硅pregistrationListener在code,但我真的不知道为什么你说,它应该在设置打开,因为打开会尝试自动登记,如果出现了一些错误,你将不会通知。

在另一方面,这个听众主要问题是由于多种原因,注册可能失败(您可以检查不同的错误响应的这里)和电流实现只通知错误codeS> = 500(这些是服务器和全局的失败),而不是其他人一样很常见的406。这一点,在我看来,在这个堆栈中的一个重要问题。

I am using native methods of sip calling and it is working fine but some time it is giving registration error IN_PROGRESS (Error Code -9 ) .I have search in Sip Error codes but dint find any error code of this kind . Here is my code for sip registration .PLease tell me if any one have idea about this error please tell me .

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.*;
import android.net.sip.*;
import java.text.ParseException;
/**
 * Handles all calling, receiving calls, and UI interaction in the WalkieTalkie app.
 */
public class WalkieTalkieActivity extends Activity implements View.OnTouchListener {

    public String sipAddress = null;
    public static SipManager manager = null;
    public static SipProfile me = null;
    public SipAudioCall call = null;
    public SipErrorCode sipcode;
    public SipException sipexeception;
    public static WalkieTalkieActivity walkiy;

    public static WalkieTalkieActivity getInstance() {
        if (walkiy == null) {
            walkiy = new WalkieTalkieActivity();
        }
        return walkiy;
    }

    @
    Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        Log.e("onCreate", "onCreate");
        initializeManager(this);
    }

    @
    Override
    public void onStart() {
        super.onStart();
        // When we get back from the preference setting Activity, assume
        // settings have changed, and re-login with new auth info.
    }

    @
    Override
    public void onDestroy() {

        super.onDestroy();
        if (call != null) {
            call.close();
        }
        closeLocalProfile();
    }

    @
    Override
    protected void onResume() {
        initializeManager(this);
        super.onResume();
    }

    public void initializeManager(Context ctx) {

        Log.e("inilitize", "initialize manager");

        if (manager == null) {
            manager = SipManager.newInstance(ctx);

        }
        initializeLocalProfile(ctx);
    }

    /**
     * Logs you into your SIP provider, registering this device as the location to
     * send SIP calls to for your SIP address.
     */
    public void initializeLocalProfile(final Context ctx) {
        Log.e("inilitize", "initialize profile");
        if (manager == null) {

            Log.e("inilitize", "return in profile");
            updateStatus("we are unable to establish this feature on your device ", ctx);
            Log.e("Wifi state", "" + SipManager.isSipWifiOnly(ctx));
            return;
        }
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
        String username = prefs.getString("namePref", "XYZ");
        String domain = prefs.getString("domainPref", "236.343.230.2");
        String password = prefs.getString("passPref", "XYZ");

        try {
            Log.e("inilitize", "building profile ");
            SipProfile.Builder builder = new SipProfile.Builder(username, domain);
            builder.setPassword(password);
            me = builder.build();
            manager.open(me);

            Log.e("alredy registered1", "" + manager.isRegistered(me.getUriString()));
            try {
                if (manager.isRegistered(me.getUriString())) {

                    Log.e("alredy registered2", "" + manager.isRegistered(me.getUriString()));
                    updateStatus("Ready", ctx);
                    return;
                }

            } catch (SipException e) {
                // TODO Auto-generated catch block
                closeLocalProfile();
                e.printStackTrace();
            }

            manager.setRegistrationListener(me.getUriString(), new SipRegistrationListener() {
                public void onRegistering(String localProfileUri) {

                    Log.e("Sip restration", "Registering with SIP Server..." + me.getUriString());
                    updateStatus("Registering with SIP Server...", ctx);
                }

                public void onRegistrationDone(String localProfileUri, long expiryTime) {
                    Log.e("Sip restration", "Ready");
                    updateStatus("Ready", ctx);

                }

                public void onRegistrationFailed(String localProfileUri, int errorCode,
                    String errorMessage) {
                    Log.e("Error Code Registration ", SipErrorCode.toString(errorCode) + " " + errorCode);
                    updateStatus(SipErrorCode.toString(errorCode), ctx);
                }
            });
        } catch (ParseException pe) {
            updateStatus("Connection Error.", ctx);
        } catch (SipException se) {
            updateStatus("Connection error.", ctx);
        }
    }

    /**
     * Closes out your local profile, freeing associated objects into memory
     * and unregistering your device from the server.
     */
    public void closeLocalProfile() {
        if (manager == null) {
            return;
        }
        try {
            if (me != null) {
                manager.unregister(me, new SipRegistrationListener() {

                    @
                    Override
                    public void onRegistrationFailed(String localProfileUri, int errorCode,
                        String errorMessage) {
                        // TODO Auto-generated method stub
                        Log.e("unregister failed", "unregister failed");

                    }

                    @
                    Override
                    public void onRegistrationDone(String localProfileUri, long expiryTime) {
                        // TODO Auto-generated method stub
                        Log.e("unregister done", "unregister done");
                    }

                    @
                    Override
                    public void onRegistering(String localProfileUri) {
                        // TODO Auto-generated method stub
                        Log.e("unregistering", "unregistering");
                    }
                });
                manager.close(me.getUriString());
            }
        } catch (Exception ee) {
            Log.d("WalkieTalkieActivity/onDestroy", "Failed to close local profile.", ee);
        }
    }

    /**
     * Make an outgoing call.
     */
    public void initiateCall(String number, final Context ctx, final View v) {


        Log.d("Number", "" + number);
        sipAddress = number;

        Log.e("initiating call", "initiating call");
        try {



            SipAudioCall.Listener listener = new SipAudioCall.Listener() {@
                Override
                public void onCallBusy(SipAudioCall call) {
                    // TODO Auto-generated method stub
                    Log.e("buzy", "buzy");
                    super.onCallBusy(call);
                }

                @
                Override
                public void onCallHeld(SipAudioCall call) {
                    // TODO Auto-generated method stub
                    Log.e("held", "held");
                    super.onCallHeld(call);
                }

                @
                Override
                public void onCalling(SipAudioCall call) {
                    // TODO Auto-generated method stub
                    Log.e("calling", "calling");
                    super.onCalling(call);
                }

                @
                Override
                public void onChanged(SipAudioCall call) {
                    // TODO Auto-generated method stub
                    Log.e("changed", "changed");
                    super.onChanged(call);
                }

                @
                Override
                public void onError(SipAudioCall call, int errorCode,
                    String errorMessage) {
                    // TODO Auto-generated method stub

                    Log.e("call error", "error" + SipErrorCode.toString(errorCode) + " " + errorCode);
                    CallingScreen.fa.finish();
                    super.onError(call, errorCode, errorMessage);
                }

                @
                Override
                public void onReadyToCall(SipAudioCall call) {
                    // TODO Auto-generated method stub
                    Log.e("ready to call", "ready to call ");
                    super.onReadyToCall(call);
                }

                @
                Override
                public void onRinging(SipAudioCall call, SipProfile caller) {
                    // TODO Auto-generated method stub
                    Log.e("ringing", "ringing");

                    super.onRinging(call, caller);
                }

                @
                Override
                public void onRingingBack(SipAudioCall call) {
                    // TODO Auto-generated method stub
                    Log.e("ringing back", "ringing back");

                    super.onRingingBack(call);
                }

                // Much of the client's interaction with the SIP Stack will
                // happen via listeners.  Even making an outgoing call, don't
                // forget to set up a listener to set things up once the call is established.
                @
                Override
                public void onCallEstablished(SipAudioCall call) {

                    Log.e("call established", "call established");
                    call.startAudio();
                    updateTime(true, ctx);
                }

                @
                Override
                public void onCallEnded(SipAudioCall call) {
                    Log.e("call ended", "call ended");

                    updateTime(false, ctx);
                    CallingScreen.fa.finish();
                }
            };

            Log.e("param 1 ", "" + me.getUriString());
            call = manager.makeAudioCall(me.getUriString(), sipAddress + "@216.245.200.2:5060", listener, 30);
        } catch (Exception e) {
            e.printStackTrace();
            Log.i("WalkieTalkieActivity/InitiateCall", "Error when trying to close manager.", e);
            if (me != null) {
                try {
                    closeLocalProfile();
                } catch (Exception ee) {
                    ee.printStackTrace();
                    Log.i("WalkieTalkieActivity/InitiateCall",
                        "Error when trying to close manager.", ee);
                    ee.printStackTrace();
                }
            }
            if (call != null) {
                call.close();
            }
        }
    }


    public void updateStatus(final String status, final Context context) {
        // Be a good citizen.  Make sure UI changes fire on the UI thread.
        this.runOnUiThread(new Runnable() {
            public void run() {
                generateNotification(context, status);

            }
        });
    }

    public void updateTime(final Boolean status, final Context context) {
        // Be a good citizen.  Make sure UI changes fire on the UI thread.
        this.runOnUiThread(new Runnable() {
            public void run() {

                if (status) {
                    CallingScreen.fa.calling_screen_text.setVisibility(View.GONE);
                    CallingScreen.fa.ch.setVisibility(View.VISIBLE);
                    CallingScreen.fa.ch.start();
                } else {
                    CallingScreen.fa.ch.stop();
                }
            }
        });
    }


    public void updateStatus(SipAudioCall call) {
        String useName = call.getPeerProfile().getDisplayName();
        if (useName == null) {
            useName = call.getPeerProfile().getUserName();
        }
        //      updateStatus(useName + "@" + call.getPeerProfile().getSipDomain());
    }


    public boolean onTouch(View v, MotionEvent event) {
        if (call == null) {
            return false;
        } else if (event.getAction() == MotionEvent.ACTION_DOWN && call != null && call.isMuted()) {
            call.toggleMute();
        } else if (event.getAction() == MotionEvent.ACTION_UP && !call.isMuted()) {
            call.toggleMute();
        }
        return false;
    }
    public void speaker(Boolean state) {
        if (call != null)
            call.setSpeakerMode(state);
    }

    public void endcall() {
        if (call != null) {
            try {
                call.endCall();
            } catch (SipException se) {
                Log.d("WalkieTalkieActivity/onOptionsItemSelected",
                    "Error ending call.", se);
            }
            call.close();
        }
    }

    public static void generateNotification(Context context, String message) {
        Log.e("inilitize", "generate notification");
        int icon = R.drawable.ic_launcher;
        long when = System.currentTimeMillis();
        NotificationManager notificationManager = (NotificationManager)
        context.getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notification = new Notification(icon, message, when);
        String title = context.getString(R.string.app_name);
        Intent notificationIntent = new Intent(context, Splash_screen.class);
        // set intent so it does not start a new activity
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
            Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent intent =
            PendingIntent.getActivity(context, 0, notificationIntent, 0);
        notification.setLatestEventInfo(context, title, message, intent);
        notificationManager.notify(0, notification);
    }
}

解决方案

SIP is a transaction based protocol, this means, every negotiation process is a transaction (e.g. a basic registration process would imply sending a REISTER request and receive 200 OK response). I posted a small example in this response.

IN_PROGRESS error initially indicates that you tried to start a new transaction, in your scenario you're trying to send a REGISTER request, when client is already in another related one.

A quite typical scenario is, in a fast logout/login, trying to register when unregistration process is still running (no 200 OK final response has been received).

Main problem regarding Android's SIP implementation and this error code is that it's used when as generic error when processing a SIP request fails so, previous meaning loses its significance.

Because of previous problem you would need to check logcat to get more information (you should see something like "~~~~~ SipSessionGroup:: processing ") but, best way to handle this, would be working with different listeners provided by the stack.

The stack provides two listeners that can get registration errors: SipRegistrationListener and SipSession.Listener. Both provides onRegistrationFailed callback but, later one, also provides onRegistrationTimeout, that can be quite helpful. Actually, you already used SipRegistrationListener in your code but I don't really get why you say that it should be set after open because open would try to automatically register and, if some error occurs, you won't be notified.

On the other hand, main problem with this listeners is that registration can fail because of several reason (you can check a list of different error responses here) and current implementation only notifies of error codes >= 500 (those are server and global failures) but not others like quite common 406. This is, in my opinion, an important bug in this stack.

这篇关于同时注册SIP错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆