31921: Stream - WebSocket - Close Error
VOICE
ERROR
This error occurs when Twilio establishes a Media Streams WebSocket connection to your server and your server then closes that connection. In bidirectional Media Streams, closing the WebSocket from your server stops the Stream.
- Your WebSocket server ended the connection and Twilio received a WebSocket close event.
- Your application closed the WebSocket for a bidirectional Stream started with
<Connect><Stream>. Twilio resumes the remaining TwiML only after your server closes the WebSocket connection. - The WebSocket connection associated with the Media Stream was closed by your server before you intended the Stream to end. Each Media Stream uses a single WebSocket connection.
- Review your WebSocket server logs to identify the close code and the condition that caused the server to end the connection.
- If you use bidirectional Media Streams with
<Connect><Stream>, keep the WebSocket connection open for as long as you want the Stream to continue. Close it only when you intend to stop the Stream. - Add a
statusCallbackURL to<Stream>so Twilio sendsstream-started,stream-stopped, andstream-errorevents. Use theStreamErrorvalue in that callback to capture more detail about the failure. - Make sure your Media Streams application accepts secure WebSocket connections from Twilio on TCP port 443.