Skip to contentSkip to navigationSkip to topbar
Page toolsOn this pageProducts used
Looking for more inspiration?Visit the

31951: Stream - Protocol - Invalid Message


WARNING: 31951

warning-31951 page anchor
VOICE
WARNING

Twilio sends warning 31951 once per Stream when your WebSocket server sends a message that does not comply with the Media Streams protocol. For bidirectional Streams, Twilio only accepts the documented media, mark, and clear message types, and each message must include the expected fields for that event.

Possible causes

possible-causes page anchor
  • The message was not valid JSON.
  • The message used an unsupported event type. Twilio only accepts media, mark, and clear messages from your server on a bidirectional Stream.
  • The message was missing required fields, included unexpected fields, or used the wrong object structure for the selected event.
  • The streamSid in the message did not match the active Stream.
  • Serialize each outbound message as valid JSON before you send it over the WebSocket connection.
  • If you need to send messages back to Twilio, use <Connect><Stream> and send only the supported media, mark, and clear events.
  • Validate each message against the documented schema before sending it. Include event, streamSid, and the correct event payload object for that message type.
  • Use the streamSid from Twilio's start message for the current Stream, and do not reuse a SID from another call or stream.

Additional resources

additional-resources page anchor