android - Sip 管理器因错误注册超时而失败(错误代码为 5)

标签 android sip

美好的一天。我正在遵循 android 开发人员网页上关于创建最简单的 sip 配置文件并打开它的简单指南。尽管甚至没有超过 1 秒,甚至没有超过 0.5 秒,sip 管理器都会返回这个超时错误...这是我的完整代码...请帮助大家:(我真的是 sip 的新手,它有什么问题?

public class CallingActivity extends AppCompatActivity {
    Button registeraccount;
    Bundle extras;
    String opponentid;
    public static final String sipdomen= "sip2sip.info";
    String myid;
    Button call;
    SipManager  mSipManager;
    SipProfile myprofile;
    SipProfile opponentprofile;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calling);
        call = (Button)findViewById(R.id.button5);
        registeraccount = (Button)findViewById(R.id.button4);
        extras = getIntent().getExtras();
        if(extras!=null){
            opponentid = extras.getString("opponentid");
            myid = extras.getString("myid");
        }
        registeraccount.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mSipManager = SipManager.newInstance(CallingActivity.this);
                SipProfile.Builder builder = null;
                try {
                    builder = new SipProfile.Builder(myid, sipdomen);
                    builder.setPassword("000000");
                    myprofile = builder.build();
                    Intent intent = new Intent();
                    intent.setAction("android.SipDemo.INCOMING_CALL");
                    PendingIntent pendingIntent = PendingIntent.getBroadcast(CallingActivity.this, 0, intent, Intent.FILL_IN_DATA);
                    mSipManager.open(myprofile, pendingIntent, null);
                    try {
                        mSipManager.setRegistrationListener(myprofile.getUriString(), new SipRegistrationListener() {
                            @Override
                            public void onRegistering(String localProfileUri) {
                                Log.d("safhaskjfa","registering");
                            }

                            @Override
                            public void onRegistrationDone(String localProfileUri, long expiryTime) {
                                Log.d("safhaskjfa","Registration succesfull"+localProfileUri+"");
                            }

                            @Override
                            public void onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage) {
                                Log.d("safhaskjfa","failed to register"+localProfileUri+"the error code is"+errorCode+"the error message is"+errorMessage);
                            }
                        });
                    } catch (SipException e) {
                        e.printStackTrace();
                    }
                } catch (ParseException e) {
                    e.printStackTrace();
                } catch (SipException e) {
                    e.printStackTrace();
                }

            }
        });
        call.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    mSipManager.makeAudioCall(myprofile,opponentprofile, new SipAudioCall.Listener(),100000);
                } catch (SipException e) {
                    e.printStackTrace();
                }
            }
        });
    }
}

最佳答案

为了确定您的请求是否被传送到注册服务器,请运行 Wireshark 并为 sip 过滤它,看看请求是否通过。

如果请求正在进行但没有回复,那么这是服务器问题,否则就是您的代码问题。

关于android - Sip 管理器因错误注册超时而失败(错误代码为 5),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32134506/

相关文章:

android - 从方向更改恢复时,DialogFragment onCreateDialog() 在 onServiceConnected() 之前被调用

android - 使用 RxJava 处理回调

call - SIP 到 WebRTC 调用。 SIP sdp正文/消息内容异常

安卓SIP语音通话: How disable noise suppression?

java - 使用字符串获取的尺寸设置文本大小

java - 按下后退按钮时,启动应用程序时会出现相同的 Activity

java - 无法创建菜单

ssl - 如何在 Wireshark (Cisco CUCM 10.5) 中通过 TLS 解密 SIP

android - 在 SipDroid 中使用 g729 编解码器时出错

java - Jain Sip - 如何创建没有 @ 的 SipUri?