2017-03-06 4 views
0

アプリのSIPコールを作成するためのGoogleのガイドラインに従っていますhttps://developer.android.com/guide/topics/connectivity/sip.html sip.zadarma.comでGoogle PlayからダウンロードしたSIPクライアントで動作するテストアカウントを作成しましたが、私のアプリでそれを登録するには私が取得: onRegistrationFailedのerrorCode = -4にErrorMessage:登録は onRegistrationFailedのerrorCode =を実行していない-9にErrorMessage:0Android SipManagerの登録に失敗しました

@Override 
protected void onResume() { 
    super.onResume(); 

    if (mNumberKeyedIn == null) 
     mNumberKeyedIn = ""; 
    if (hasSIPPermissions()) { 
     initializeSIP(); 
    } else { 
     requestSIPPermission(); 
    } 
} 

@Override 
public void onPause() { 
    super.onPause(); 
    closeLocalProfile(); 
} 

public void closeLocalProfile() { 
    if (mSipManager == null) { 
     return; 
    } 

    try { 
     if (mSipProfile != null) { 
      mSipManager.close(mSipProfile.getUriString()); 
      if (mSipManager.isRegistered(mSipProfile.getProfileName())) 
       mSipManager.unregister(mSipProfile, null); 
     } 
    } catch (Exception e) { 
     Log.d(TAG, "Failed to close local profile.", e); 
    } 
} 

private void initializeSIP() { 

    if (callReceiver == null) { 
     IntentFilter filter = new IntentFilter(); 
     filter.addAction("com.xxxx.android.apps.xxxx.activity.INCOMING_CALL"); 
     callReceiver = new IncomingCallReceiver(); 
     this.registerReceiver(callReceiver, filter); 
    } 

    try { 
     if (mSipManager == null) { 
      mSipManager = SipManager.newInstance(this); 
      if (!SipManager.isVoipSupported(this)) { 
       Toast.makeText(this, getString(R.string.sip_not_supported), Toast.LENGTH_SHORT).show(); 
       return; 
      } 
      if (SipManager.isSipWifiOnly(this)) { 
       Toast.makeText(this, getString(R.string.sip_wifi_only), Toast.LENGTH_SHORT).show(); 
      } 
     } 

     if (mSipProfile != null) { 
      closeLocalProfile(); 
     } 

     SipProfile.Builder builder = new SipProfile.Builder(BuildConfig.SIP_USERNAME, BuildConfig.SIP_DOMAIN); 
     builder.setPassword(BuildConfig.SIP_PASSWORD); 
     //builder.setProtocol("TCP"); 
     //builder.setAuthUserName(BuildConfig.SIP_USERNAME); 
     //builder.setPort(5060); 
     //builder.setOutboundProxy(BuildConfig.SIP_OUTBOUND_PROXY); 
     builder.setAutoRegistration(true); 
     mSipProfile = builder.build(); 

     Intent intent = new Intent(); 
     intent.setAction("com.xxxx.android.apps.xxxx.activity.INCOMING_CALL"); 
     PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, Intent.FILL_IN_DATA); 
     mSipManager.open(mSipProfile, pendingIntent, null); 
     mSipManager.setRegistrationListener(mSipProfile.getUriString(), new SipRegistrationListener() { 

      public void onRegistering(String localProfileUri) { 
       updateStatus(getString(R.string.sip_registering), R.drawable.circle_orange, false); 
       Log.d(TAG, "onRegistering " + localProfileUri); 
      } 

      public void onRegistrationDone(String localProfileUri, long expiryTime) { 
       updateStatus(getString(R.string.sip_ready), R.drawable.circle_green, true); 
       Log.d(TAG, "onRegistrationDone " + localProfileUri + " expiryTime = " + expiryTime); 
      } 

      public void onRegistrationFailed(String localProfileUri, int errorCode, 
              String errorMessage) { 
       updateStatus(getString(R.string.sip_registration_failed), R.drawable.circle_red, false); 
       Log.e(TAG, "onRegistrationFailed " + localProfileUri + " errorCode = " + errorCode + " errorMessage: " + errorMessage); 
      } 
     }); 
    } catch (ParseException e) { 
     e.printStackTrace(); 
     Toast.makeText(this, getString(R.string.sip_not_configured), Toast.LENGTH_SHORT).show(); 
    } catch (SipException e) { 
     e.printStackTrace(); 
     Toast.makeText(this, getString(R.string.oops_something_went_wrong_short), Toast.LENGTH_SHORT).show(); 
    } catch (Exception e) { 
     e.printStackTrace(); 
     Toast.makeText(this, getString(R.string.sip_not_supported), Toast.LENGTH_SHORT).show(); 
    } 
} 

すべてのヘルプははるかに高く評価されます。

答えて

0

SipClientのコードを調べる前に、以下の解決策を試してからRegistrationサーバーをテストする必要があります。

  1. VoIP SoftPhoneクライアントを実行して、サーバーが動作していない場合は、その最初のポート番号/ IPアドレスの問題をデバッグしてください。
  2. ステップ1が動作している場合は、サーバからWiresharkを実行して、クライアントからの着信REGISTRATIONリクエストからの応答を追跡してみてください。

テキストの「エラーログ」からは、IPアドレスはping可能ですが、登録ポート番号は開かれていないことを意味します。

私はこれがコードの問題ではないと思います。確かにあなたのセットアップの問題でなければなりません。

関連する問題