From 0444665228fa21410fbc50502ebf5e975a3598b0 Mon Sep 17 00:00:00 2001
From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com>
Date: Tue, 5 Nov 2019 09:38:28 -0500
Subject: [PATCH] sip: prevent checkNATAddress refresh registeration
 immediately

- For OVH sip trunk, if too many registeration requests are sent
  at the same time, it will send back a 500 status code to prevent
  us sending registeration request in certain time period.

- That means at the starting of the programme, the account is not
  registered, which is the cause of the issue #643

Change-Id: I89dd7331704c6abdf1021c3e3cecd2b55516c4d1
---
 src/sip/sipaccount.cpp | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/src/sip/sipaccount.cpp b/src/sip/sipaccount.cpp
index 88f1bd40b1..3c3346a483 100644
--- a/src/sip/sipaccount.cpp
+++ b/src/sip/sipaccount.cpp
@@ -1932,27 +1932,9 @@ SIPAccount::checkNATAddress(pjsip_regc_cbparam *param, pj_pool_t *pool)
 
     if (contactRewriteMethod_ == 2 && regc_ != nullptr) {
         contactOverwritten_ = true;
-
-        /*  Unregister old contact */
-        try {
-            tmp_tp = transport_;
-            sendUnregister();
-        } catch (const VoipLinkException &e) {
-            JAMI_ERR("%s", e.what());
-        }
-
-        // sendUnregister may failed and cause regc_ to be reset to nullptr
-        // in this case re-registration has been scheduled, so just leave
-        if (!regc_)
-            return true;
         pjsip_regc_update_contact(regc_, 1, &contact_);
 
-        /*  Perform new registration */
-        try {
-            sendRegister();
-        } catch (const VoipLinkException &e) {
-            JAMI_ERR("%s", e.what());
-        }
+        /*  Perform new registration at the next registration cycle */
     }
 
     return true;
-- 
GitLab