Asterisk and FreeSWITCH SIP trunk troubleshooting
Most trunk problems leave the same traces in a capture. Take one on the PBX (sngrep, tcpdump or the logs of the PBX), open it in the workbench, then follow the step that matches the symptom. Settings are those of Asterisk with PJSIP and of FreeSWITCH with Sofia.
The trunk does not register
Symptom: REGISTER is answered 401 or 407 again and again, then 403; or the provider never answers.
In the capture: Open the REGISTER exchange in the digest authentication debugger: it tells a wrong realm, a reused nonce count or a wrong password.
Asterisk (PJSIP)
- pjsip show registrations, then pjsip set logger on to see the exchange.
- Check outbound_auth on the registration and the username, password and realm of its auth section.
- server_uri and client_uri must use the domain the provider expects, not its IP address, when it hosts several domains.
- After a 403, Asterisk waits forbidden_retry_interval before trying again.
FreeSWITCH
- sofia status gateway <name> shows the state; sofia global siptrace on shows the messages.
- Check username, password and realm of the gateway; set from-domain when the provider checks it.
- register=false for a trunk authenticated by IP address, which then needs no REGISTER.
The trunk is unreachable
Symptom: Calls fail with 408 or 503; OPTIONS get no answer.
In the capture: Look for requests without any response: the request leaves, nothing comes back. A message above 1300 bytes over UDP may be fragmented and dropped: check it with the SIP MTU calculator.
Asterisk (PJSIP)
- qualify_frequency on the aor sends OPTIONS and shows the trunk as unreachable when they fail.
- Check DNS SRV and the transport: TLS on port 5061 needs a certificate the provider trusts.
- identify with match= must list every address the provider sends from, or its requests fall into the anonymous endpoint.
FreeSWITCH
- ping=30 on the gateway sends OPTIONS; sofia status gateway <name> shows it down when they fail.
- Check the proxy and the transport of the gateway, and that the profile listens on the right address.
Inbound calls fail
Symptom: The provider sends an INVITE, and gets 404, 484 or 403 back.
In the capture: The 404 or 484 pages list the usual causes; compare the Request-URI and the To header with your dial plan.
Asterisk (PJSIP)
- The context of the endpoint must have an extension for the number as it arrives: with or without +, the country code, or the whole DID.
- Without a matching identify section, the call reaches the anonymous endpoint, or is refused.
FreeSWITCH
- Calls of the external profile go to the public context: add an extension that matches the destination number as it arrives.
- Check the ACL of the profile when calls are refused with 403.
One-way or no audio
Symptom: The call is answered, but one side, or both, hear nothing.
In the capture: The workbench shows streams in one direction only and the private addresses of the SDP. The one-way audio capture shows the pattern.
Asterisk (PJSIP)
- On the transport: external_media_address and external_signaling_address set to the public address, and local_net for each private network.
- On the endpoint: direct_media=no, rtp_symmetric=yes, force_rport=yes and rewrite_contact=yes behind NAT.
- Open the RTP range of rtp.conf in the firewall, and turn SIP ALG off on the router.
FreeSWITCH
- ext-rtp-ip and ext-sip-ip set to the public address (or autonat:), and apply-nat-acl for clients behind NAT.
- NDLB-force-rport for devices that do not ask for rport.
- Open rtp-start-port to rtp-end-port of switch.conf.xml in the firewall.
Calls drop after 32 seconds
Symptom: The call is answered, then ends 32 s later.
In the capture: The 200 OK is retransmitted and no ACK comes: open the call-drop autopsy, or the missing ACK capture.
Asterisk (PJSIP)
- The Contact of the 200 OK must be reachable from the provider: set external_signaling_address and local_net.
- rewrite_contact=yes keeps the Contact of devices behind NAT usable.
FreeSWITCH
- ext-sip-ip must be the public address, so that the Contact of the 200 OK can be reached.
- Turn SIP ALG off on the router: it often rewrites the Contact badly.
Calls drop after 15 or 30 minutes
Symptom: Long calls always end at the same duration.
In the capture: Look for Session-Expires in the INVITE and the 200 OK, and for re-INVITE or UPDATE refreshes: the call-drop autopsy tells a session timer that expired without refresh.
Asterisk (PJSIP)
- timers=yes with timers_sess_expires and timers_min_se that the provider accepts; timers=no if the provider does not refresh.
- Refreshes need the endpoint to accept UPDATE or re-INVITE from the provider.
FreeSWITCH
- enable-timer and session-timeout on the profile; minimum-session-expires must not exceed what the provider offers.
- A firewall that forgets idle UDP flows can drop the refresh: check its timeouts.
Calls fail with 488
Symptom: The INVITE is answered 488 Not Acceptable Here.
In the capture: Compare the m= lines of the offer and the codecs the other side supports with the SDP inspector; the codec mismatch capture shows the pattern.
Asterisk (PJSIP)
- disallow=all then allow= with the codecs of the provider, such as ulaw, alaw and g729.
- SRTP: media_encryption must match what the provider expects.
FreeSWITCH
- inbound-codec-prefs and outbound-codec-prefs of the profile must share a codec with the provider.
- inbound-codec-negotiation=generous accepts the codecs of the provider in its order.
Keypad digits are not received
Symptom: IVR menus or voicemail ignore the digits.
In the capture: The workbench marks RFC 4733 events, SIP INFO digits and tones found in the audio in the call flow.
Asterisk (PJSIP)
- dtmf_mode=rfc4733 when the provider offers telephone-event in the SDP, inband for G.711 calls without it, info only if the provider asks.
FreeSWITCH
- dtmf-type=rfc2833 (the RFC 4733 events) on the profile, rfc2833-pt matching the provider, or start_dtmf for in-band digits.
Faxes fail
Symptom: Fax calls connect, then fail after a few seconds or pages.
In the capture: Look for the re-INVITE to image/t38 and its answer: a 488 means the other side cannot switch to T.38.
Asterisk (PJSIP)
- t38_udptl=yes with t38_udptl_ec=redundancy, and fax_detect=yes to switch on the CNG tone.
FreeSWITCH
- fax_enable_t38=true and fax_enable_t38_request=true on the channel, or G.711 pass-through with t38_passthru.
Before sharing a capture with a provider, remove the personal data with the anonymizer.