---
"@context": https://schema.org
"@type": TechArticle
"@id": https://www.twilio.com/docs/api/errors/31950#article
headline: "31950: Stream - Protocol - Malformed Message"
url: https://www.twilio.com/docs/api/errors/31950
inLanguage: en
dateModified: 2026-04-29T19:18:40.000Z
author:
  "@type": Organization
  name: Twilio Developer Education Team
publisher:
  "@type": Organization
  name: Twilio
---

# 31950: Stream - Protocol - Malformed Message

Log Type: APPLICATION

Log Level: WARNING

## Description

Twilio couldn't decode a message sent on the Media Streams WebSocket connection. Twilio sends this warning once per Stream.

### Possible causes

* Your WebSocket server sent a message in binary format.
* Your application sent raw audio bytes directly over the WebSocket instead of sending a text message that matches the Media Streams message format.

### Possible solutions

* Send Media Streams messages as text WebSocket messages. Do not use binary frames.
* If you send audio to Twilio on a bidirectional Stream, send a `media` message with a `media.payload` value instead of sending raw binary audio.
* Encode audio in `media.payload` as base64 `audio/x-mulaw` audio at 8000 Hz.
* Review the supported WebSocket message formats for `media`, `mark`, and `clear` messages.

#### Additional resources

* [Media Streams WebSocket messages](/docs/voice/media-streams/websocket-messages)
* [Media Streams overview](/docs/voice/media-streams)
* [TwiML Voice: `<Stream>`](/docs/voice/twiml/stream)
