From 2ae937ca185286b9718345f190bdafc468c33b61 Mon Sep 17 00:00:00 2001 From: Denys Smirnov Date: Thu, 6 Nov 2025 22:03:27 +0200 Subject: [PATCH] Fix media timeout when getting no ACK. --- pkg/sip/media_port.go | 13 +++++++++---- pkg/sip/service.go | 6 ++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/pkg/sip/media_port.go b/pkg/sip/media_port.go index 8b8aec4b..f0ac1deb 100644 --- a/pkg/sip/media_port.go +++ b/pkg/sip/media_port.go @@ -229,6 +229,15 @@ func (p *MediaPort) disableTimeout() { } func (p *MediaPort) enableTimeout(initial, general time.Duration) { + if initial <= 0 || general <= 0 { + p.log.Warnw("attempting to set zero media timeout", nil, "initial", initial, "timeout", general) + if initial <= 0 { + initial = defaultMediaTimeoutInitial + } + if general <= 0 { + general = defaultMediaTimeout + } + } p.timeoutInitial.Store(&initial) p.timeoutGeneral.Store(&general) select { @@ -253,10 +262,6 @@ func (p *MediaPort) EnableTimeout(enabled bool) { } func (p *MediaPort) SetTimeout(initial, general time.Duration) { - if initial <= 0 { - p.disableTimeout() - return - } p.enableTimeout(initial, general) } diff --git a/pkg/sip/service.go b/pkg/sip/service.go index 9f981035..09ff5575 100644 --- a/pkg/sip/service.go +++ b/pkg/sip/service.go @@ -73,6 +73,12 @@ func NewService(region string, conf *config.Config, mon *stats.Monitor, log logg if log == nil { log = logger.GetLogger() } + if conf.MediaTimeout <= 0 { + conf.MediaTimeout = defaultMediaTimeout + } + if conf.MediaTimeoutInitial <= 0 { + conf.MediaTimeoutInitial = defaultMediaTimeoutInitial + } s := &Service{ conf: conf, log: log,