Production‑Grade SIP Trunk Registration & Call Recording – PJSIP vs Asterisk?

Hello everyone,

I’m looking for guidance on designing a production‑grade SIP trunk handling and call recording setup, and I’d appreciate advice from people who have built or operated similar systems at scale.


Current Requirement

I have a SIP trunk from a SIP provider that must be registered to an intermediate SIP service / voice gateway. This gateway needs to:

  1. Register the SIP trunk (acts as the SIP endpoint for the provider)

  2. Allow calls to flow through this trunk

  3. Record all calls traversing the trunk (both inbound and outbound)

  4. Forward or hand off the calls to downstream services (e.g., voice agents, webhooks, or other call‑processing services)

  5. Be suitable for production use and scale

So effectively, I need a SIP “SPC / voice gateway” that sits between:

  • Endpoint A: SIP provider

  • Endpoint B: Downstream call‑processing / voice agent services


What I Have Today

Currently, I have a basic PJSIP‑based framework where:

  • I register the SIP trunk using PJSIP

  • Incoming calls are handled in code

  • The call is routed/forwarded to another service (e.g., a webhook or voice agent)

  • Some call handling logic exists, but this setup is not production‑grade

This works for development and proof‑of‑concept, but I’m concerned about:

  • Scalability

  • Reliability and fault tolerance

  • Operational management

  • Call recording at scale

  • Monitoring, failover, and maintainability


What I’m Evaluating

I’m considering whether replacing my custom PJSIP framework with a production‑ready SIP platform such as Asterisk would better serve this use case.

Specifically, I would like to understand:

  1. Can Asterisk (using PJSIP) act as the SIP gateway that:

    • Registers a SIP trunk to the provider

    • Handles inbound/outbound calls

    • Records calls reliably

    • Forwards calls to external services or applications?

  2. Would Asterisk be a better fit than a custom PJSIP implementation for:

    • Production stability

    • Scaling to higher call volumes

    • Operational tooling (logging, monitoring, recording, HA)

    • Long‑term maintenance

  3. Are there known architectural patterns where:

    • Asterisk (or a similar PBX / SBC‑like system) handles SIP + recording

    • Application logic lives downstream (e.g., voice bots, APIs, webhooks)?

Hi,

Have you tried Asterisk at all, or even read the documentation? You’re asking questions that are obvious if you have put any effort into researching it at all.

I’d suggest you look into Asterisk Rest Interface (ARI) programming for Asterisk. It sounds like what you want to do would be a good fit for that. With it you can either record using the native Asterisk record functionality, or record in the ARI application itself. Doing the latter also allows you to do whatever you want with analyzing or forwarding the call audio to other services. I have done recording very reliably via both methods, depending on the end goal.

Asterisk can also interface with a UniMRCP server if something like that would be useful for your scenario.

Are there known architectures that do what you’re asking, yes, many I’m sure, including several I’ve built myself. Does it fit your specific application, or work better than your custom PJSIP implementation? Only you can decide that.

You’re absolutely right — I haven’t yet done a deep comparison of all the available platforms.

So far, the main option that came to mind was Asterisk, but I haven’t worked with it extensively, which is why I’m unsure whether it’s the right choice for my use case. My first question is simply whether it can fully serve the purpose I’m aiming for — specifically, acting as a production‑grade SIP gateway / SBC with call recording and call forwarding capabilities.

Assuming it can serve that purpose, my second question is about alternatives. Are there other platforms that would be a better fit for this kind of setup? I’m particularly interested in solutions that are:

  • Proven and reliable in production

  • Require the least amount of engineering effort to reach production readiness

  • Easier to operate and scale

Right now, I have a working PJSIP‑based POC, but my concern is that turning this into a fully production‑ready system may require significant additional effort. What I’m trying to understand is whether that assessment is correct — and if so, whether moving to another platform you mentioned (or have experience with) would ultimately be a more efficient path.

I’d really appreciate your perspective based on real‑world experience: which approach or platform would you recommend that balances effort vs. reliability, and why?

On Sunday 12 April 2026 at 11:53:11, hrasheed911 wrote:

So far, the main option that came to mind was Asterisk, but I haven’t
worked with it extensively, which is why I’m unsure whether it’s the right
choice for my use case. My first question is simply whether it can fully
serve the purpose I’m aiming for — specifically, acting as a
production‑grade SIP gateway / SBC with call recording and call forwarding
capabilities.

I would suggest that the existence of commercial systems based on Asterisk
such as PBXware | Bicom Systems Wiki and https://www.thirdlane.com is
a good enough indication that Asterisk is indeed capable of doing what you’re
asking about.

Note that Asterisk is not an SBC, which you have mentioned without saying what
SBC functions you expect to use, however in your original posting you listed a
number of things you wanted the resultant system to be able to do, and then
just summarised that as “a SIP ‘SBC / voice gateway’”, so I’m not convinced
you actually want / need the full functions of an SBC.

Everything else you listed in your original posting can be done with Asterisk.

You also mentioned:

  • Scalability
  • this is difficult / impossible to answer without an idea of “what scale?”
  • you need to have some numbers such as
    • number of endpoint devices attached to the system
    • number of call setups per second / minute / hour
    • number of concurrent calls going over your upstream SIP connection
  • Reliability and fault tolerance
  • there are external solutions which can help with this such as pacemaker /
    corosync / shared storage devices / bonded networking / etc, but these are not
    part of Asterisk
  • Operational management
  • this is a vague requirement and entirely external to Asterisk
  • Call recording at scale
  • again “what scale?”
  • are you talking about:
    • total quantity of recordings / storage capacity?
    • number of concurrent calls being recorded?
  • Monitoring, failover, and maintainability
  • monitoring is external to Asterisk and can be done with systems such as
    Icinga, Grafana and many others
  • failover is in my opinion part of reliability and fault tolerance above
  • maintainability is just as vague a requirement as “operational management”
    above, and is external to Asterisk

I hope this helps.

Antony.


Schrödinger’s rule of data integrity: the condition of any backup is unknown
until a restore is attempted.

What I’m Trying to Achieve

I have an on‑premise telephony system that handles live customer calls. Separately, I have an AI voice agent running in the cloud. The goal is to allow a live customer, who calls into the on‑prem telephony system, to interact with the AI agent in real time (bi‑directional voice).

The challenge is that the AI agent itself:

  • Is not a SIP endpoint

  • Cannot act as an SBC

  • Cannot register a SIP trunk

  • Communicates only via WebSockets / APIs

Because of this, a middleware layer is required.


Proposed Architecture / Call Flow

To bridge this gap, I need a containerized SBC‑like middleware running in the cloud that performs the following:

  1. Registers a SIP trunk with the on‑prem telephony system (or SIP provider)

  2. Terminates SIP signaling (INVITE, ACK, BYE, etc.)

  3. Handles:

    • SDP negotiation

    • Codec negotiation

    • RTP stream establishment

    • Transcoding if required

  4. Once RTP is established, bridges the media to the AI agent using:

    • WebSockets or webhook‑based APIs
  5. Supports call recording, as audio recordings and transcripts are mandatory requirements


Current Implementation (Working POC)

At the moment, I have a working proof‑of‑concept implemented as follows:

  • PJSIP handles:

    • SIP trunk registration

    • SIP signaling

    • Media establishment (RTP)

    • Codec negotiation / transcoding

  • A Python layer:

    • Hooks into the call lifecycle

    • Bridges audio to the AI agent using WebSockets / APIs

    • Manages call metadata

  • Bi‑directional RTP is successfully established

  • The AI agent can converse with a real caller end‑to‑end

Functionally, this works, and all parties are “happy” at the POC level.


Scale & Production Requirements

  • Expected load: ~1 CPS (call per second)

  • Maximum burst: 2 CPS

  • Calls are conversational (AI voice agent)

  • Call recording is mandatory

  • Platform must be stable, observable, and production‑ready

  • Deployed in containers (Docker / cloud environment)


Why I’m Asking for Guidance

My concern is not whether this is possible — I’ve already proven that it is with PJSIP.

The real question is about effort vs. production readiness:

  • How much work does it realistically take to harden a custom PJSIP‑based SBC for production (HA, fault tolerance, monitoring, edge cases, SIP interoperability)?

  • Would using a more established platform (for example, Asterisk or anything else you’ve worked with) reduce overall effort and risk, given this use case?

  • Are there other platforms better suited for such arch

For production use, Asterisk with PJSIP is a better choice than a custom PJSIP setup.

It can handle SIP trunk registration, inbound/outbound calls, and reliable call recording out of the box. It also provides better stability, logging, and scalability.

A common approach is to use Asterisk as the SIP gateway (handling SIP and recording) and keep application logic in downstream services like voice bots or APIs.

Custom PJSIP works for testing, but Asterisk is more suitable for production environments.

So to rephrase your request, you are looking for a production ready “SBC”/VoIP solution that can provide SIP Trunking functionality to your on-premises phone system as well as allow websocket connection to your AI agent, with call recording always enabled. Correct?

Are your PBX and AI agent directly reachable from the internet or are they behind some kind of VPN?