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

Sip Manager failed with error Registration Time Out (Error Code is 5)

美好的一天。我遵循 android 开发人员网页中关于创建最简单的 sip 配置文件并打开它的简单指南。虽然甚至没有超过 1 秒,甚至 0.5 秒,sip 管理器 returns 我这个超时错误......这是我的完整代码......请帮助大家:(我真的是 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 并查看请求是否通过。

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