Node.js SIP and RTP toolbox used for building a User Agent Client (UAC), a User Agent Server (UAS), routers, IVR flows, and small VoIP test applications.
This workspace has been hardened for the available test flow:
npm testpasses: 17 tests.examples/b2bua_local_ivr_test.jsproves a local 127.0.0.1 client-to-IVR call can be acknowledged and kept alive past the 4-second range observed on the external CallCentric test.- The IVR environment test in
examples/ivr_env_test.jsuses UDP, direct G.711 uLaw RTP, RTCP sender reports, and loopback-safe NAT binding via the local configuredSIP_LOCAL_IP.
- UDP SIP transport.
- UAC registration and outbound calls.
- UAS handling for registration, INVITE, ACK, and BYE.
- Route-based dispatch through
SIP Router. - User endpoint support through
SIP UserManager. - IVR endpoint support through
SIP IVRManager. - RTP sessions that can bind to a local IPv4 address and advertise a different IPv4 RTP IP.
- Direct raw
ulawmedia streaming as RTP. - RFC 2833 DTMF detection and duplicate-event suppression.
- Local loopback test that removes carrier/NAT/handset behavior from the SIP media test.
- Node.js 18 or newer.
ffmpegfor regenerating or converting prompt media.- Shell environment variables or
examples/.envcredentials. - Network UDP permissions for SIP and RTP.
Install dependencies if needed:
npm installCheck credentials in examples/.env or your .env:
SIP_USERNAME=...
SIP_PASSWORD=...
SIP_SERVER=sip.callcentric.net
SIP_TARGET=...
SIP_PORT=5060
SIP_LOCAL_IP=192.168.1.215
Run the built-in test suite:
npm testRun the integration suite:
node --test tests/integration.test.jsRun the local no-carrier IVR test:
node --test examples/b2bua_local_ivr_test.jsRun the external IVR environment test:
SIP_HANGUP_AFTER_MS=0 SIP_TIMEOUT_MS=60000 node examples/ivr_env_test.js 2>/dev/nullexamples/ivr_env_test.js registers a UAC, makes one call, and connects a raw RTP session. Its diagnostics include:
- INVITE/ACK/200 signaling.
- Outbound raw
ulawstreaming. - RTCP sender reports.
- Inbound packet counts.
- Remote
BYEtiming. - DTMF acceptance.
Useful environment values:
SIP_HANGUP_AFTER_MS=0
SIP_TIMEOUT_MS=60000
SIP_LOCAL_IP=<advertised_or_local_IP>
SIP_LOCAL_PORT=0examples/b2bua_local_ivr_test.js creates a 127.0.0.1 UAS, routes a local client to an IVR endpoint, and verifies the call remains alive beyond the external 4-second symptom. This test isolates the library from carrier and handset behavior.
- Direct raw media uses 160-byte, 20 ms, 8 kHz, G.711 uLaw payloads.
- RTCP basic sender report timing is used to keep the media stream identifiable to providers.
- Inbound RTP DTMF packets are deduplicated to suppress RFC 2833 retransmission noise.
- Media examples assume PCMU for the direct IVR path.
npm testandnode --test tests/integration.test.jsare the fastest confidence checks.- For IVR external calls, logs containing
DTMF accepted: 1indicate that digit traffic is reaching the application. - Logs containing
Remote BYE receivedare generated by the far side. They are useful for separating carrier/handset hangs from local failures. - Inbound packet counts help determine whether RTP is arriving even when audio is not audible.
- A local
b2bua_local_ivr_test.jsrun isolates library behavior from network and phone behavior.
- Transport is UDP IPv4 only.
- SIP authentication and digest handling are basic.
- TCP, TLS, STUN/TURN, ICE, SRTP, video, and full B2BUA media bridging are not implemented.
- The IVR environment example does not maintain multiple concurrent calls.
- Registration retry handling may still require more work for strict or changing proxy nonce sequences.
index.js: top-level VOIP construction in client or server mode.SIP/: SIP parsing, building, auth, routing, transport, trunk, user, and IVR support.RTP/: RTP listeners, SDP/Session handling, and rawulawstreaming.SDP/: SDP parser.examples/: client, server, and IVR test programs.tests/: regression tests for auth, builders, parsers, routing, RTP, and integration behavior.
MIT License.