Issues with WebRTC endpoint for M5/ESP device
# support
j
I recently attended VapiCon, and Sean DuBois, w/ Open AI held a workshop where he configured a small ESP device to talk to a VAPI assistant. In his GitHub docs, he uses the endpoint “https://staging-webrtc.vapi.api/“ I’m wondering if it’s pointing at some kind of vapi dev environment that I’m unable to access because I keep getting an error when I attempt to do so. Is there a different endpoint URL I should be using for WebRTC? GitHub: https://github.com/VapiAI/vapicon-2025-hardware-workshop
c
Hi JTrannVA, If you're facing issues with WebSocket call connectivity or errors in processing WebSocket audio, you might want to ensure the proper handling of WebSocket connections and audio data formats. Here's a quick guide: 1. **WebSocket Connection**: Make sure your WebSocket connection is correctly established using the URL provided in the API response. Ensure you handle connection events like
open
,
close
, and
error
properly. 2. **Audio Format**: The audio format (
pcm_s16le
or
mulaw
) should align with your configuration. Verify the format used for sending and receiving audio data matches your initial setup. 3. **Sending Audio Data**: Use the correct process to convert and send audio data if you're capturing it from devices. For instance, for PCM, convert float audio samples to Int16 values before sending. 4. **Receiving Data**: Ensure you properly distinguish between binary audio data and JSON control messages when handling data received over the WebSocket. You can initiate calls and configure audio formats by following the examples provided in the [WebSocket Transport Documentation](https://docs.vapi.ai/calls/websocket-transport). If you encounter specific issues, such as errors while sending or receiving data, or unexpected WebSocket behavior, check your console logs for detailed error messages or any discrepancies between expected and actual WebSocket events. For more tailored troubleshooting, detailed call logs and scenarios might be required, so ensure you have accurate setup information and issue details handy.
j
Is this endpoint no longer active? I chatted with the workshop host from OpenAI and he’s wondering if it was brought offline: https://staging-webrtc.vapi.api/“
c
We are checking with the team to see if the endpoint is still active.
j
REOPEN
Just a quick update on this. It's been a couple of weeks since I last tested it, but I did get further than I had initially. Worked with Sriram who notified us that the demo environment was back up. Now when I try connecting the device, it's establishing the WebRTC connection, I can see in my console log that it's registering my button press on the device, but when I try speaking into it, I hear no response and there's nothing in the logs on the VAPI side. Anything else you can think of that I might be missing? Probably a little outside of the wheel house for what you'd normally troubleshoot, but I just think these things are so cool and can imagine there will eventually be a decent market for things like this in the future.
c
If there is no log in VAPI, there must be something missing from the pipeline to not establish a full call. I will have to talk to Sri some more about this since he's the expert with hardware implementations. In the meantime, could you send over some details about how you're starting the webRTC connection and how you've tried connecting with an assistant?
j
Here's a step by step of how it should work from start to finish. This was created from this github repo; https://github.com/VapiAI/vapicon-2025-hardware-workshop: 1. Device Initialization Boot ESP32-S3 device Initialize NVS flash and network stack Connect to WiFi using configured credentials Initialize libpeer WebRTC library Create Opus audio codec (16kHz, 20ms frames) 2. WebRTC Configuration Configure peer connection with: STUN server: stun:stun.cloudflare.com:3478 Audio codec: Opus (no video) Audio receive callback for handling AI responses 3. WHIP Signaling (WebRTC HTTP Ingestion Protocol) Generate SDP offer describing device capabilities HTTP POST to https://staging-webrtc.vapi.ai/ Headers: Content-Type: application/sdp, Authorization: Bearer [token] Body: JSON with assistantId + SDP offer as multipart data Receive SDP answer from Vapi (HTTP 200) Filter ICE candidates (keep relay candidates only) Set remote description with Vapi's SDP answer 4. ICE Connection Establishment Resolve STUN server and perform STUN binding Exchange ICE candidates between device and Vapi Connection states: new → checking → connected → completed When connected: display logo and start audio task 5. Audio Streaming (Active Call) Sending (Push-to-talk): Loop every 15ms checking button state If button pressed: Record 640 samples → Encode with Opus → Send via RTP Receiving: Receive Opus packets from Vapi via WebRTC Decode to PCM (640 samples) Play through I2S speaker 6. Connection Maintenance Background loop handles STUN keepalives and RTP packets Auto-restart device on disconnect/failure
c
I will send you a DM shortly
6 Views