VonyxDocs

Asterisk

Send and receive calls through Vonyx with PJSIP.

View this page as Markdown

Connect Asterisk to Vonyx with a PJSIP trunk. You get outbound calls on your Vonyx numbers, and inbound calls into your dialplan.

Before you start

  • A Vonyx SIP trunk with a number attached
  • Asterisk 16 or later with res_pjsip (PJSIP)
  • A public IP or hostname for Asterisk, with UDP 5060 and your RTP range open to 43.204.9.41

Outbound calls

Add the trunk to pjsip.conf

Replace the username and password with your trunk's values. There is no registration section: Vonyx checks credentials on each call and doesn't need Asterisk to register.

pjsip.conf
[transport-udp]
type = transport
protocol = udp
bind = 0.0.0.0:5060
; Behind NAT only: your public IP and your LAN
;external_media_address = 203.0.113.10
;external_signaling_address = 203.0.113.10
;local_net = 192.168.1.0/24
 
[vonyx-auth]
type = auth
auth_type = userpass
username = your_trunk_username
password = your_trunk_password
 
[vonyx]
type = aor
contact = sip:43.204.9.41:5060
 
[vonyx]
type = endpoint
transport = transport-udp
context = from-vonyx
disallow = all
allow = ulaw,alaw
outbound_auth = vonyx-auth
aors = vonyx
direct_media = no
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
 
[vonyx]
type = identify
endpoint = vonyx
match = 43.204.9.41

ulaw and alaw are PCMU and PCMA, the only codecs Vonyx supports. On recent Asterisk releases auth_type = userpass is deprecated and treated as digest; either works.

Set NAT if Asterisk is behind a router

If Asterisk has a private IP, uncomment the three NAT lines on the transport:

  • external_media_address and external_signaling_address: your public IP. Asterisk writes it into SIP headers and the SDP for traffic leaving local_net.
  • local_net: your LAN range. Add one line per range.

Forward UDP 5060 and your RTP range to Asterisk, and turn off SIP ALG on the router.

Set the RTP port range

Vonyx sends RTP from UDP 10000–20000. Your own range, set in rtp.conf, must be open to 43.204.9.41:

rtp.conf
[general]
rtpstart = 10000
rtpend = 20000

Add the outbound dialplan

Outbound calls must use one of your Vonyx numbers as caller ID.

extensions.conf
[outbound]
exten => _91XXXXXXXXXX,1,Set(CALLERID(num)=91XXXXXXXXXX)
 same => n,Dial(PJSIP/${EXTEN}@vonyx,60)
 same => n,Hangup()

Include outbound in the context your phones use.

Inbound calls

Add the inbound context

The identify section matches calls from 43.204.9.41 to the vonyx endpoint, which sends them to from-vonyx.

extensions.conf
[from-vonyx]
exten => _X.,1,Answer()
 same => n,Playback(hello-world)
 same => n,Hangup()

Replace these steps with your IVR, queue or agent.

Point Vonyx at Asterisk

In the Vonyx console, open the trunk, turn on Inbound calls, and set Inbound address to Asterisk's public host, for example pbx.example.com:5060. See Inbound calls.

Test the connection

asterisk -rx "core reload"
asterisk -rx "pjsip show endpoint vonyx"
asterisk -rx "channel originate PJSIP/91XXXXXXXXXX@vonyx application Playback hello-world"

The originate call rings 91XXXXXXXXXX and plays a prompt when answered. Then call your Vonyx number from a mobile and check that it reaches from-vonyx. Use pjsip set logger on to see the SIP messages.

Limitations

  • DTMF and call transfer are not available on Vonyx yet. Don't rely on Read() / IVR key presses or Transfer() on Vonyx calls.
  • New accounts make 1 call at a time (raise limits).
  • No TLS or SRTP: use a UDP or TCP transport on port 5060.

Troubleshooting

ProblemFix
401 or 407 that never succeedsCheck username and password in vonyx-auth, and that the endpoint has outbound_auth = vonyx-auth.
429 after auth succeedsThe caller ID isn't one of your Vonyx numbers.
Inbound calls rejected or sent to the wrong contextCheck the identify section matches 43.204.9.41 and that pjsip show identifies lists it.
488 Not Acceptable HereAllow only ulaw and alaw on the endpoint.
One-way or no audioSet external_media_address, external_signaling_address and local_net behind NAT, and open your rtp.conf range to 43.204.9.41.

More in SIP troubleshooting.

On this page