Skip to main content

What you’ll build

You run Routr and a NATS server with Docker Compose, turn on EdgePort’s NATS publisher, and subscribe to the events with the nats CLI. When you register two softphones and call between them, you see routr.endpoint.registered, routr.call.started, and routr.call.ended messages arrive. Call events come from EdgePort, so you can feed them to billing, dashboards, or any service that speaks NATS without touching the SIP path.

Prerequisites

  • Docker with Docker Compose
  • The nats CLI
  • Node.js and npm, to install rctl
  • Two SIP softphones
  • The IP address of your machine on your local network (for example, 192.168.1.3)

Steps

1

Define the services

Create a folder for the tutorial and a compose.yaml file inside it. It runs a NATS server and routr-one with the NATS publisher turned on.Filename: compose.yaml
EdgePort reads three variables:
2

Start the stack

Start the services. Replace the address with your own.
Confirm that EdgePort connected to NATS.
The output includes a line that ends like this:
The log line above appears, and the routr container stays up.
3

Subscribe to Routr events

Create a nats CLI context for the local server and select it.
Subscribe to every subject under routr. Leave this running.
4

Create a Domain and two Agents

In another terminal, install rctl.
Create a Domain with the SIP URI sip.local.
Create credentials and an Agent for 1001, then repeat for 1002. Pick the Domain sip.local and the matching credentials when rctl agents create asks.
The --insecure flag is required because this setup doesn’t use TLS on the API.
5

Register the softphones

Configure each softphone with one Agent: its username and password, sip.local as the domain, and your machine’s IP (for example, 192.168.1.3:5060) as the outbound proxy over UDP.Each successful registration publishes an event.
You see one routr.endpoint.registered message per softphone. Softphones re-register periodically, so more arrive over time.
6

Make a call

From 1001, call 1002. When Routr forwards the INVITE, EdgePort publishes routr.call.started.
Hang up. EdgePort publishes routr.call.ended with the same callId.
Terminal running nats sub routr.call.started and receiving a JSON event with callId, from, to, and startTime

routr.call.started as shown by nats sub (captured on an earlier release, so the fields differ slightly)

Terminal running nats sub routr.call.ended and receiving a JSON event with callId, endTime, and hangupCause NORMAL_CLEARING

routr.call.ended as shown by nats sub (captured on an earlier release)

For one call you see one routr.call.started and one routr.call.ended, and both carry the same callId.

Event reference

extraHeaders holds every header in the message whose name starts with X-. For a list of hangup causes, see HangupCauses.java. To change the prefix, set NATS_PUBLISHER_SUBJECT. For example, NATS_PUBLISHER_SUBJECT=myserver publishes myserver.call.started, myserver.call.ended, and myserver.endpoint.registered.
To print events to EdgePort’s log instead of NATS while you debug, set CONSOLE_PUBLISHER_ENABLED=true.

Clean up

Stop and remove the containers, and delete the CLI context.

Next steps

EdgePort

EdgePort configuration and environment variables.

Environment variables

Every variable Routr reads, by component.

SIP headers

The X- headers Routr adds and reads.

Deploy with Docker

Run Routr with Docker in production.