Go to the latest version of this document.

# ``twisted`.`web`.`websocket``

module documentation
(source)

Websocket (rfc6455) client and server support.

For websocket servers, place a `WebSocketResource` into your Twisted Web resource hierarchy.

For websocket clients, create a new endpoint via `WebSocketClientEndpoint.new` with the WebSocket server URL and then, on the newly created endpoint, call `WebSocketClientEndpoint.connect`.

Both client-side and server-side application code must conform to `WebSocketProtocol`.

Note
To use this module, you must install Twisted's `websocket` extra, i.e. `pip install twisted[websocket]`.

Class | `WebSocketClientEndpoint` | A `WebSocketClientEndpoint` describes an URL to connect to and a way of connecting to that URL, that can connect a `WebSocketClientFactory` to that URL.
Class | `WebSocketClientFactory` | A `WebSocketClientFactory` is a factory for a particular kind of `WebSocketProtocol` that implements client-side websocket listeners via `WebSocketClientEndpoint`.
Class | `WebSocketProtocol` | An object that conforms to `WebSocketProtocol` can receive all the events from a websocket connection.
Class | `WebSocketResource` | A `WebSocketResource` is a `Resource` that presents a websocket listener. You can install it into any twisted web server resource hierarchy.
Class | `WebSocketServerFactory` | A `WebSocketServerFactory` is a factory for a particular kind of `WebSocketProtocol` that implements server-side websocket listeners via `WebSocketResource`.
Class | `WebSocketTransport` | The transport that can send websocket messages.
Exception | `ConnectionRejected` | A websocket connection was rejected by an HTTP response.