Skip to content

[Question] SIP OPTIONS always return 200 OK #764

Description

@codextrail

Hi team,

I am experimenting the LiveKit platform and to connect the telephony clients to the platform I am using an SIP Proxy with the list of LiveKit SIP nodes in the load balancer list.

While testing the LiveKit SIP graceful shutdown I realize the service still handling new SIP INVITEs and new calls can be established even the server is already in shutdown mode.

Usually SIP proxies can be configured to probe the destinations using SIP OPTIONS and take the destination out of the list if SIP OPTION response is not successful.

The current SIP OPTION handler always return the 200 OK status. There is any specific reason for the behavior implemented?

func (s *Server) onOptions(log *slog.Logger, req *sip.Request, tx sip.ServerTransaction) {
	_ = tx.Respond(sip.NewResponseFromRequest(req, sip.StatusOK, "OK", nil))
}

There is already some flows (createSIPParticipant) where the service Health is being validate. Would it make sense to use the same validation in SIP OPTION handler?

func (s *Server) onOptions(log *slog.Logger, req *sip.Request, tx sip.ServerTransaction) {
	if h := s.mon.Health(); h != stats.HealthOK {
		_ = tx.Respond(sip.NewResponseFromRequest(req, sip.StatusServiceUnavailable, "Service Unavailable", nil))
		return
	}
	_ = tx.Respond(sip.NewResponseFromRequest(req, sip.StatusOK, "OK", nil))
}

With such approach the User Agent can react accordingly the SIP OPTION result (for example not proxy new SIP INVITEs) if the destination is not healthy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions