Caracola.UACAutoOutbound (Caracola v0.1.0-rc.1)

Copy Markdown View Source

Automatic registrations with outbound (RFC 5626). Equivalent to NkSIP's nksip_uac_auto_outbound.

defmodule MyUA do
  use Malla.Service,
    plugins: [Caracola.UACAutoOutbound],
    sip: [listen: "sip:all:5060"]
end

{:ok, true} = Caracola.UACAutoOutbound.start_register(MyUA, :reg1, "<sip:registrar.com;transport=tcp>")

It uses Caracola.UACAutoRegister and Caracola.Outbound. Registrations started with start_register/4 get a reg-id (the :reg_id option, or the next free one) and, if the registrar supports outbound, their flow is kept alive with CRLF pings (TCP and TLS) or STUN requests (UDP), every Flow-Timer seconds of the registrar or the defaults below (minus up to 20%). When the flow fails, or a registration fails, it is sent again after a random time between 50% and 100% of min(max_time, base * 2^failures), where base is all_fail if all the outbound registrations are failing and any_ok otherwise (RFC 5626 §4.5).

Configuration

Under the :uac_auto_outbound key (seconds):

  • :all_fail - base time when all the registrations fail (30).
  • :any_ok - base time when some registration works (90).
  • :max_time - maximum time between retries (1800).
  • :udp_ttl - keepalive interval for UDP (25).
  • :tcp_ttl - keepalive interval for TCP and TLS (120).

Summary

Functions

Returns the outbound registrations: their id, if the last one was successful, the seconds to the next one and the number of consecutive failures.

Functions

get_registers(service)

@spec get_registers(module()) :: [
  {term(), boolean() | nil, integer(), non_neg_integer()}
]

Returns the outbound registrations: their id, if the last one was successful, the seconds to the next one and the number of consecutive failures.

start_register(service, id, uri, opts \\ [])

@spec start_register(module(), term(), String.t() | Caracola.URI.t(), list()) ::
  {:ok, boolean()} | {:error, term()}

Starts an automatic registration with outbound. See Caracola.UACAutoRegister.start_register/4.

stop_register(service, id)

@spec stop_register(module(), term()) :: :ok | :not_found

Stops an automatic registration. See Caracola.UACAutoRegister.stop_register/2.