Search code examples
androidsip

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


Good Day. I'm following a simple guide from the android developers' webpage on creating the simplest sip profile and opening it. Though even not passing 1 second, or even 0.5 second, the sip manager returns me this error of time out...here is my full code... Please help guys: (I'm really new to sip and what's wrong with it?

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();
                }
            }
        });
    }
}

Solution

  • To make sure your request is transmitted or not to registration sever, please run Wireshark and filter it for sip and see if the request is passing through.

    If the request is going and no-reply is coming then it's the server problem otherwise it's your code problem.