How the agent application is actually communicate ...
# ask-ai
b
How the agent application is actually communicate to Frontend application? Is it through WebRTC or Web Socket?
t
Thanks for reaching out, Gopi. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking whether the agent app communicates with the frontend via WebRTC or WebSocket — the agent communicates with the frontend using WebRTC for media, and WebSockets are used only for signaling/control. • Media (audio/video): sent peer-to-peer through WebRTC connections (agent and frontend both join the same LiveKit room). • Signaling/control (e.g., connection setup, text transcriptions, RPCs): handled over WebSocket where needed, but not used for the actual media stream. Sources: Web and mobile frontends | LiveKit docs | OpenAI and LiveKit partner to turn Advanced Voice into an API
b
I understand from your answer is that WebSocket will be used for the initial connection setup that is handshake between agent and livekit service?
t
You're asking if WebSocket is used for the initial handshake between the agent and LiveKit — yes. • WebSocket (or another signaling channel) handles connection setup and control messages required to establish the WebRTC peer connection (exchange of SDP/ICE candidates, room join, participant metadata). • The actual media (audio/video) flows over the established WebRTC peer connection (RTP), routed by the LiveKit server. Would you like a brief sequence of the handshake steps (join → SDP/ICE exchange → media) or details for a specific SDK?
b
yes
t
Below is a concise step-by-step handshake showing how the agent uses a signaling channel (WebSocket) to establish a WebRTC media connection with the frontend client in a LiveKit room. 1. Agent and frontend open signaling channels ◦ Both clients establish a signaling/ control channel to the LiveKit server (typically WebSocket or the SDK’s signaling transport). 1. Join room / authenticate ◦ Each client sends a room join request with its token/credentials and participant metadata (role
AGENT
for agent). 1. Exchange join responses ◦ LiveKit confirms joins and returns room/participant state (existing participants, tracks, etc.). 1. Create local offer (one side) ◦ The initiating client (could be frontend or agent) creates a WebRTC SDP offer describing supported codecs, sources, and ICE candidates. 1. Send offer via signaling ◦ The offer is sent to LiveKit over the signaling channel; LiveKit relays it to the target participant(s) in the room. 1. Create answer (other side) ◦ The receiving client creates an SDP answer and local ICE candidates. 1. Send answer via signaling ◦ The answer is sent back over the signaling channel through LiveKit. 1. ICE candidate exchange ◦ Both clients gather and exchange ICE candidates via signaling until connectivity is established (direct or via TURN). 1. DTLS/SRTP setup and media start ◦ DTLS handshake completes, SRTP keys are established, and RTP media (audio/video) begins flowing over the WebRTC peer connection routed by LiveKit. 1. Ongoing control via signaling ◦ Further control messages (mute/unmute, track add/remove, metadata updates, text transcriptions, RPCs) use the signaling channel. Media continues over the WebRTC connection. If you want, I can: • Show the same sequence for a specific SDK (JavaScript, Android, iOS, or a server agent). • Draw out which side typically initiates the offer in common LiveKit setups. Which would you prefer?