Live audio teardown

Live Azan over VoIP: rooms, tokens, and secure listening

A first-hand account of streaming Azan and Khutbah live so masjid members can listen from anywhere, without sharing one microphone token with the whole community.

By MyAlMasjid Engineering Published 18 August 2026 Reviewed by the same team that ships Live Azan

Why generic “live audio” advice failed us

A masjid Azan is not a podcast and not a Zoom call. It is a short, time-critical broadcast that must:

Per-minute vendor billing made Friday Khutbah unpredictable. We moved media to a self-hosted server and kept business logic in our API. The app only receives a short-lived token. It never holds the media secret.

Experience, not a tutorial clone: we originally tracked “who is listening” from the chat connection. That drifted from reality whenever a phone slept. The media server’s participant list is now the source of truth, excluding the publisher so the Imam sees listener count, not “1 including me”.

The broadcast path we actually run

Live Azan broadcast path 1. Muezzin Start Imam / Muezzin app 2. Create room unique room name 3. Publisher token can publish 4. Push notify Members woken 5. Listen token listen only Live audio (not a file download) Muezzin microphone to media server to member speakers Azan rooms close after 5 minutes. Khutbah rooms after 90 minutes. TCP fallback when UDP is blocked on a mobile network.
Figure 1. Session control (API + push) is separate from the live audio path.
  1. The Muezzin or Imam, already role-checked on the API, starts a session of type Azan or Qutbah.
  2. The API creates a unique live-audio room for that session only — Azan and Khutbah stay separate.
  3. A publisher token is minted so only that Imam or Muezzin can use the microphone.
  4. A push notification wakes subscribed members of that masjid only — not the entire app install base.
  5. Each member’s app requests a listen-only token and joins the same room.

Publisher vs subscriber tokens

This split is the entire security model. If we issued one “room token” to everyone, a compromised member device could shout over the Azan.

GrantPublisher (Imam / Muezzin)Subscriber (member)
Join roomYesYes
Publish microphoneYesNo
Subscribe to audioYes (monitor own send)Yes
Publish data channelNoNo
Token lifetimeShort-lived (covers a long Khutbah)Short-lived

Tokens are minted on the server. The media API secret never sits in the Flutter binary or in Git.

What breaks on some mobile networks

WebRTC prefers UDP. Some mobile networks and office Wi-Fi drop or throttle UDP. Members would see “connecting…” while the Muezzin was already reciting.

Max participantsThousands per room
Empty room timeoutAbout a minute
Azan hard cap5 minutes
Khutbah hard cap90 minutes

Duration caps that match worship, not Zoom

Generic conferencing defaults (hours-long rooms) are dangerous in a masjid product. A forgotten “End” button would keep a microphone live in an empty hall.

What we would not do again

  1. Do not bill live worship per minute. Friday spikes punish the masjid that is doing the most good.
  2. Do not let the client decide whether it is a publisher. Role checks belong on the API.
  3. Do not use listener counts from the chat socket. Use the media server’s participant list.
  4. Do not skip a TCP fallback if your users are on networks that block UDP.

Related reading: cross-platform architecture and roles · product feature list.