Skip to contentSkip to navigationSkip to topbar
Page tools
Useful for sharing or LLM
Accelerate development with AI

On this pageProducts used
Looking for more inspiration?Visit the
Error
Application error

31901: Stream - WebSocket - Connection Timeout

Twilio Voice DocumentationVoice

Description

description page anchor

Twilio returns this error when the Media Stream connection request does not receive a response from your WebSocket server. Twilio uses the url in <Stream> to establish a secure wss connection, and your Media Streams application must allow secure WebSocket traffic on TCP port 443.

Possible causes

possible-causes page anchor
  • Your WebSocket server is not connected to a network or is otherwise unreachable.
  • The url in <Stream> points to the wrong host or IP address. Twilio uses that url to open the WebSocket connection.
  • An intermediate service such as ngrok, a proxy, or another routing layer is not forwarding traffic to your WebSocket server.
  • A firewall or network policy is blocking secure WebSocket traffic on TCP port 443.
  • Confirm that your WebSocket server is online, connected to the network, and reachable from Twilio.
  • Verify that the <Stream> url is correct and uses wss. wss is the only supported protocol for Media Streams.
  • If you use ngrok, a proxy, or another intermediate service, verify that it routes traffic to your WebSocket server and returns a response.
  • Update your firewall rules to allow secure WebSocket connections on TCP port 443 from Twilio to your WebSocket server.
  • After you restore connectivity, confirm that your server receives Twilio's initial connected event on the WebSocket connection.

Additional resources

additional-resources page anchor