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,