WebSocketTransport enables a purely WebSocket based connection between clients and your Pipecat application. It implements bidirectional audio and video streaming using a WebSocket for real-time communication.
This transport is intended for lightweight implementations, particularly for local development and testing. It expects your Pipecat server to include the corresponding WebSocketTransport server-side implementation.
The
WebSocketTransport is best suited for server-server applications and prototyping client/server apps.For client/server production applications, we strongly recommend using a WebRTC-based transport for robust network and media handling. For more on WebRTC vs. Websocket communication, check out this article.Usage
Basic Setup
API Reference
Constructor Options
Properties
TransportConnectionParams
TheWebSocketTransport takes the same options as the constructor; WebSocketTransportOptions. Anything provided here will override the defaults set in the constructor. The wsUrl is required to establish a connection.
Methods
For most operations, you will not interact with the transport directly. Most methods have an equivalent in thePipecatClient and should be called from the PipecatClient. However, there is one transport-specific methods that you may need to call directly. When doing so, be sure to access your transport via the transport property of the PipecatClient instance.
If implementing your own serializer, you will need to pass the user audio
stream to the transport via this method, which takes an
ArrayBuffer of audio
data.Events
The transport implements the variousPipecatClient event handlers.