Go to the latest version of this document.

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

class documentation

`class WebSocketClientEndpoint: (source)`

Constructor: `WebSocketClientEndpoint.new(reactor, url, tlsPolicy, connectTimeout, ...)`

View In Hierarchy

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 Method | `new` | Construct a `WebSocketClientEndpoint` from a reactor and a URL.
Async Method | `connect` | Make an outgoing connection to this `WebSocketClientEndpoint`'s HTTPS connection.
Class Variable | `endpointFactory` | an `IAgentEndpointFactory` that constructs agent endpoints when `connect`
Class Variable | `url` | the URL to connect to.

@classmethod
def new(cls, reactor: `IReactorTCP`, url: `str`, tlsPolicy: `IPolicyForHTTPS` = BrowserLikePolicyForHTTPS(), connectTimeout: `int | None` = None, bindAddress: `bytes | None` = None) -> `WebSocketClientEndpoint`: (source)

Construct a `WebSocketClientEndpoint` from a reactor and a URL.

Parameters
reactor:`IReactorTCP` | The reactor to use for the TCP connection.
url:`str` | a string describing an URL where a websocket server lives.
tlsPolicy:`IPolicyForHTTPS` | The TLS policy to use for HTTPS connections.
connectTimeout:`int | None` | The number of seconds for the TCP-level connection timeout.
bindAddress:`bytes | None` | The bind address to use for the TCP client connections.

Returns
`WebSocketClientEndpoint` | the newly constructed endpoint.

async def connect(self, protocolFactory: `WebSocketClientFactory[_WSP]`) -> `_WSP`: (source)

Make an outgoing connection to this `WebSocketClientEndpoint`'s HTTPS connection.

Parameters
protocolFactory:`WebSocketClientFactory[_WSP]` | The constructor for the protocol.

Returns
`_WSP` | A coroutine (that yields `Deferred`s) that completes with the connected `WebSocketProtocol` once the websocket connection is established.

endpointFactory: `IAgentEndpointFactory` = (source)

an `IAgentEndpointFactory` that constructs agent endpoints when `connect`

url: `str` = (source)

the URL to connect to.