From d67ff5e163e178f3057bec82f55be67e658d1b81 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 24 May 2021 15:41:59 +0300 Subject: [PATCH] Added delay on error from disconnect session --- sessions/sessions.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sessions/sessions.go b/sessions/sessions.go index 6fe305dc6..bfe431089 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -559,7 +559,11 @@ func (sS *SessionS) debitLoopSession(s *Session, sRunIdx int, dscReason = err.Error() } // try to disconect the session n times before we force terminate it on our side + fib := utils.Fib() for i := 0; i < sS.cgrCfg.SessionSCfg().TerminateAttempts; i++ { + if i != 0 { // not the first iteration + time.Sleep(time.Duration(fib()) * time.Millisecond) + } if err = sS.disconnectSession(s, dscReason); err == nil { s.Unlock() return @@ -594,10 +598,17 @@ func (sS *SessionS) debitLoopSession(s *Session, sRunIdx int, s.Lock() defer s.Unlock() // try to disconect the session n times before we force terminate it on our side + fib := utils.Fib() for i := 0; i < sS.cgrCfg.SessionSCfg().TerminateAttempts; i++ { + if i != 0 { // not the first iteration + time.Sleep(time.Duration(fib()) * time.Millisecond) + } if err = sS.disconnectSession(s, utils.ErrInsufficientCredit.Error()); err == nil { return } + utils.Logger.Warning( + fmt.Sprintf("<%s> could not disconnect session: %s, error: %s", + utils.SessionS, s.cgrID(), err.Error())) } utils.Logger.Warning( fmt.Sprintf("<%s> could not disconnect session: <%s>, error: <%s>",