sip注册失败-尝试了3个不同的帐户



我需要在我的应用程序中包含一部对讲机。我总是收到一个注册失败-9错误代码。我创建了两个免费的Sip帐户(sip2sip.info,Sip.linphone.org(和一个商业帐户(onsip.com(。我添加了所有这些权限:

<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_SIP" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />

以及以下功能:

<uses-feature android:name="android.hardware.sip.voip" android:required="true" />
<uses-feature android:name="android.hardware.wifi" android:required="true" />
<uses-feature android:name="android.hardware.microphone" android:required="true" />

我在onCreate:中调用上述操作

void log_and_register()
{
try
{
c.DEBUG().ftrace("VOIP Supported: " + SipManager.isVoipSupported(c.ma()));
c.DEBUG().ftrace("SIP API Supported: " + SipManager.isApiSupported(c.ma()));
mSipManager = SipManager.newInstance(c.ma());
SipProfile.Builder builder = new SipProfile.Builder(c.config().getSIP_UserName(), c.config().getSIP_Domain());
builder.setPassword(c.config().getSIP_Password());
//builder.setProtocol("UDP"); //"TCP");
//builder.setPort(5060);   //5080  5070   
builder.setAutoRegistration(true);
mSipProfile = builder.build();
}
catch (ParseException pe)
{
c.DEBUG().ftrace("incapable of parsing domain name, username or password!");
c.DEBUG().ASSERT(0 == 1);
}
try
{
Intent intent = new Intent();
intent.setAction("android.SipDemo.INCOMING_CALL");
PendingIntent pendingIntent = PendingIntent.getBroadcast(c.ma(), 0, intent, Intent.FILL_IN_DATA);
mSipManager.open(mSipProfile, pendingIntent, null);
}
catch (SipException se)
{
c.DEBUG().ftrace("WALKIE TALKIE NOT WORKING - Sip Exception!!");
c.DEBUG().ASSERT(0 == 1);
}
if (ContextCompat.checkSelfPermission(c.ma(), Manifest.permission.USE_SIP) == PackageManager.PERMISSION_GRANTED)
c.DEBUG().ftrace("GRANTED!!!");
else
ActivityCompat.requestPermissions(c.ma(), new String[]{Manifest.permission.USE_SIP}, 1);
try
{
if (mSipManager.isRegistered(mSipProfile.getUriString()))
{
c.DEBUG().ftrace("already registered !!" + mSipManager.isRegistered(mSipProfile.getUriString()));
return;
}
}
catch (Exception e)
{
c.DEBUG().ftrace("NO!!");
}

try
{
//mSipManager.register(mSipProfile, 30, new SipRegistrationListener(){
//mSipManager.register(mSipProfile, 30000, new SipRegistrationListener(){
c.DEBUG().ftrace("THIS IS THE TRACE BEFORE REGISTATION : " + mSipProfile.getUriString());
mSipManager.setRegistrationListener(mSipProfile.getUriString(), new SipRegistrationListener()
{
public void onRegistering(String localProfileUri)
{
c.DEBUG().ftrace("Registering with SIP Server...");
}
// next version has it!!
public void onRegistrationTimeout() {}
public void onRegistrationDone(String localProfileUri, long expiryTime)
{
c.DEBUG().ftrace("SIP Ready");
}
public void onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage)
{
// -9 signifie qu'il y a un appel en cours
c.DEBUG().ftrace("CANNOT REGISTER domain=" + c.config().getSIP_Domain() + " / username=" + c.config().getSIP_UserName());
c.DEBUG().ftrace("SIP ERROR MSG : localProfileUri=" + localProfileUri + "   errorCode=" + errCode(errorCode) + "  errorMessage=" + errorMessage);
}
});
}
catch (Exception e)
{
c.DEBUG().ftrace("Cannot initialise wakie talkie!");
c.DEBUG().ASSERT(0 == 1);
}

// https:github.com/aosp-mirror/platform_development/commit/a025796211f15c2796f8ea3208c066801aa250b6
initiateCall();
}
public SipAudioCall call = null;
public void initiateCall() {
try {
SipAudioCall.Listener listener = new SipAudioCall.Listener() {
// 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) {
call.startAudio();
call.setSpeakerMode(true);
call.toggleMute();
}
@Override
public void onCallEnded(SipAudioCall call) {
}
};
c.DEBUG().ftrace("rafael - Format="+mSipProfile.getUriString());
//call = mSipManager.makeAudioCall(mSipProfile.getUriString(), sipAddress, listener, 30);
call = mSipManager.makeAudioCall(mSipProfile.getUriString(), "sip:rafael.hogue@sip2sip.info", listener, 30);
} catch (Exception e) {
Log.i("WalkieTalkieActivity/InitiateCall", "Error when trying to close manager.", e);
if (mSipProfile != null) {
try {
mSipManager.close(mSipProfile.getUriString());
} catch (Exception ee) {
Log.i("WalkieTalkieActivity/InitiateCall",
"Error when trying to close manager.", ee);
ee.printStackTrace();
}
}
if (call != null) {
call.close();
}
}
}

我为Nougat编译,因为我使用了不推荐使用的函数。然后我修改了我的代码,用奥利奥编译。我使用Firewall Voip Checker来检查我与SIP服务器的连接,测试1是成功的,但第二个接缝处于无限循环中。测试的一个结果引起了我的注意,但我不知道它意味着什么:

检查NAT类型

100%/被阻止或无法访问STUN服务器(但它是绿色的,所以我想它通过了测试??(。我有一面旗帜:

android.useDeprecatedNdk=真实

我把它改成假的。。。我总是收到返回代码"注册失败">

我做了这个动作来查看-9错误代码是什么:

//有关详细信息,请参阅//注册时出现Sip错误//如何通过SIP发送即时消息//https://developer.android.com/reference/android/net/sip/SipErrorCodeprivate字符串errCode(int iErrorCode({字符串sErr=";

switch (iErrorCode)
{
case CLIENT_ERROR:
sErr = "client error!!";
break;
case CROSS_DOMAIN_AUTHENTICATION:
sErr = "cross domain authentification!!";
break;
case DATA_CONNECTION_LOST:
sErr = "data connection lost!!";
break;
case INVALID_CREDENTIALS:
sErr = "invalid credentials!!";
break;
case INVALID_REMOTE_URI:
sErr = "invalid remote uri!!";
break;
case IN_PROGRESS:
sErr = "In progress!!";
break;
case NO_ERROR:
sErr = "No error!!";
break;
case PEER_NOT_REACHABLE:
sErr = "peer not reachable!!";
break;
case SERVER_ERROR:
sErr = "server error!!";
break;
case SERVER_UNREACHABLE:
sErr = "server unreachable!!";
break;
case SOCKET_ERROR:
sErr = "socket error!!";
break;
case TIME_OUT:
sErr = "time out!!";
break;
case TRANSACTION_TERMINTED:
sErr = "No transaction terminated!!";
break;
default:
sErr = "No error detected!!";
break;
}
return (sErr);
}

错误信息是"正在进行…",这意味着他已经很忙了,但我不知道这意味着什么。

我什么时候通过维基百科上的错误代码来获得潜在问题的线索:

https://en.wikipedia.org/wiki/List_of_SIP_response_codes#4xx.E2.80.94Client_Failure_Responses

我试图找到一个更高杠杆的SDK来实现我的对讲机,并找到了。

我搜索了wireshark应用程序,但我只在笔记本电脑上找到了它,而不是在我的android智能手机上。

对我来说,安装对讲机很重要,因为我正在创建一个应用程序来提高小学日托的安全性,我们需要相互沟通。

我尝试更改端口和通信协议,并尝试将"自动注册"标志设置为true。

我试着在注册失败后打电话,以防公开声明在假设它可能试图第二次注册的情况下进行注册。

我不知道了!!

我将在没有sip帐户的情况下实现WIFI对讲机。参考:stackoverflow.com/questions/11176988/…

然后,在启动时,我会将每个智能手机的端口信息、ip地址、用户名(我的同事使用(保存到我的firebase(在线数据库(中,以便建立通信,而无需向用户提出任何要求,使其自动化。

我意识到,如果我在连接本应工作的示例代码时遇到问题,这可能意味着我的客户将遇到我希望避免的同样类型的问题。

我不需要与不在同一网络上的人通信,但我认为这种方法也可以在互联网上工作,即使是在其他路由器上的客户端,如果他们都连接到互联网的话。

相关内容

最新更新