Core API reference¶
Functions¶
- async picows.ws_connect(
- ws_listener_factory,
- url,
- *,
- ssl_context=None,
- disconnect_on_exception=True,
- websocket_handshake_timeout=5,
- logger_name=None,
- enable_auto_ping=False,
- auto_ping_idle_timeout=10,
- auto_ping_reply_timeout=10,
- auto_ping_strategy=<WSAutoPingStrategy.PING_WHEN_IDLE: 1>,
- enable_auto_pong=True,
- max_frame_size=10485760,
- extra_headers=None,
- max_redirects=5,
- proxy=None,
- read_buffer_init_size=16384,
- socket_factory=None,
- use_aiofastnet=None,
- **kwargs,
Open a WebSocket connection to a given URL.
This function forwards its kwargs directly to asyncio.loop.create_connection
- Parameters:
ws_listener_factory (Callable[[], WSListener] | Callable[[WSUpgradeRequest, WSUpgradeResponse], WSListener]) – A factory function that returns a user handler. The factory may either accept no arguments, or accept the negotiated
WSUpgradeRequestandWSUpgradeResponse. The returned handler has to derive fromWSListener.url (str) – Destination URL
ssl_context (SSLContext | None) – optional SSLContext to override default one when the wss scheme is used
disconnect_on_exception (bool) – Indicates whether the client should initiate disconnect on any exception thrown from WSListener.on_ws_frame callbacks
websocket_handshake_timeout (float | None) – is the time in seconds to wait for the websocket client to receive websocket handshake response before aborting the connection. Set to
Noneto disable the timeout.logger_name (str | Logger | LoggerAdapter | None) – Logger name suffix or logger-like object used for logging. If a string is provided, picows will use picows.<logger_name>. If
Noneis provided, picows will usepicows.client.enable_auto_ping (bool) –
Enable detection of a stale connection by periodically pinging remote peer.
Note
This does NOT enable automatic replies to incoming ping requests. enable_auto_pong argument controls it.
auto_ping_idle_timeout (float) –
- when auto_ping_strategy == PING_WHEN_IDLE
how long to wait before sending ping request when there is no incoming data.
- when auto_ping_strategy == PING_PERIODICALLY
how often to send ping
auto_ping_reply_timeout (float) – how long to wait for a pong reply before shutting down connection.
auto_ping_strategy (WSAutoPingStrategy) –
An
WSAutoPingStrategyenum value:PING_WHEN_IDLE - ping only if there is no new incoming data.
PING_PERIODICALLY - send ping at regular intervals regardless of incoming data.
enable_auto_pong (bool) – If enabled, picows will automatically reply to incoming PING frames.
max_frame_size (int) –
Maximum allowed frame size. Disconnect will be initiated if client receives a frame that is bigger than max size.
extra_headers (Mapping[str, str] | Iterable[tuple[str, str]] | None) – Arbitrary HTTP headers to add to the handshake request.
max_redirects (int) –
How many times we can follow HTTP redirects. Set to 0 in order to disable redirects.
proxy (str | None) – Optional proxy URL. Supported schemes are
http://,socks4://andsocks5://(including authenticated variants). HTTPS proxy scheme (https://) is currently not supported.read_buffer_init_size (int) – Initial size (in bytes) of the internal read buffer. The buffer grows exponentially when incoming data does not fit. Unlike max_frame_size (a safety limit), this value affects actual memory allocation, so very large values increase baseline memory usage.
socket_factory (Callable[[WSParsedURL], socket | None | Awaitable[socket | None]] | None) –
Optional socket factory. Can be a regular function or coroutine. Receive WSParsedURL object as the only argument. Returns pre-created socket. Returning
Nonefalls back to the default connection path.The returned socket may be either already connected to the provided endpoint or unconnected. If unconnected, picows will connect it.
If
proxyis set,WSParsedURLpassed to the factory is proxy endpoint coordinates, not final WebSocket server coordinates.use_aiofastnet (bool | None) – Use aiofastnet package to create client and server connections instead of
loop.create_server,loop.create_connectionnative method. picows will use aiofastnet by default if it is installed. You can override default behavior by using this argument.
- Returns:
WSTransportobject and a user handler returned by ws_listener_factory(), or by ws_listener_factory(request, response) when using the two-argument client factory form.- Return type:
tuple[WSTransport, WSListener]
- async picows.ws_create_server(
- ws_listener_factory,
- host=None,
- port=None,
- *,
- disconnect_on_exception=True,
- websocket_handshake_timeout=5,
- logger_name=None,
- enable_auto_ping=False,
- auto_ping_idle_timeout=20,
- auto_ping_reply_timeout=20,
- auto_ping_strategy=<WSAutoPingStrategy.PING_WHEN_IDLE: 1>,
- enable_auto_pong=True,
- max_frame_size=10485760,
- read_buffer_init_size=16384,
- use_aiofastnet=None,
- **kwargs,
Create a WebSocket server listening on a TCP port at the host address. This function forwards its kwargs directly to asyncio.loop.create_server
It has a few extra parameters to control WebSocket behavior.
- Parameters:
ws_listener_factory (Callable[[WSUpgradeRequest], WSListener | WSUpgradeResponseWithListener | None]) –
A factory function that accepts WSUpgradeRequest object and returns one of:
User handler object. A standard 101 response will be sent to the client.
WSUpgradeResponseWithListener object. This allows to send a custom response with extra headers and an optional body.
None. In such case 404 Not Found response will be sent and the client will be disconnected.
The user handler must derive from WSListener and is responsible for processing incoming data.
The factory function acts as a router.
WSUpgradeRequestcontains the requested path and headers. Different user listeners may be returned depending on the path and other conditions.host –
The host parameter can be set to several types which determine where the server would be listening:
If host is a string, the TCP server is bound to a single network interface specified by host.
If host is a sequence of strings, the TCP server is bound to all network interfaces specified by the sequence.
If host is an empty string or None, all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6).
port – specify which port the server should listen on. If 0 or None (the default), a random unused port will be selected (note that if host resolves to multiple network interfaces, a different random port will be selected for each interface).
disconnect_on_exception (bool) – Indicates whether the client should initiate disconnect on any exception thrown by WSListener.on_ws_frame callback
websocket_handshake_timeout (float | None) – is the time in seconds to wait for the websocket server to receive websocket handshake request before aborting the connection. Set to
Noneto disable the timeout.logger_name (str | Logger | LoggerAdapter | None) – Logger name suffix or logger-like object used for logging. If a string is provided, picows will use picows.<logger_name>. If
Noneis provided, picows will usepicows.server.enable_auto_ping (bool) –
Enable detection of a stale connection by periodically pinging remote peer.
Note
This does NOT enable automatic replies to incoming ping requests. enable_auto_pong argument controls it.
auto_ping_idle_timeout (float) –
- when auto_ping_strategy == PING_WHEN_IDLE
how long to wait before sending ping request when there is no incoming data.
- when auto_ping_strategy == PING_PERIODICALLY
how often to send ping
auto_ping_reply_timeout (float) – how long to wait for a pong reply before shutting down connection.
auto_ping_strategy –
An
WSAutoPingStrategyenum value:PING_WHEN_IDLE - ping only if there is no new incoming data.
PING_PERIODICALLY - send ping at regular intervals regardless of incoming data.
enable_auto_pong (bool) – If enabled, picows will automatically reply to incoming PING frames.
max_frame_size (int) –
Maximum allowed frame size. Disconnect will be initiated if the server side receives a frame that is bigger than the max size.
read_buffer_init_size (int) – Initial size of the internal read buffer. The buffer grows exponentially if new data doesn’t fit. You may set this to the actual expected maximum frame size but don’t push it too much. Contrary to max_frame_size which is just a safety check, setting big value here will force picows to actually allocate the specified amount of memory.
use_aiofastnet (bool | None) – Use aiofastnet package to create client and server connections instead of
loop.create_server,loop.create_connectionnative method. picows will use aiofastnet by default if it is installed. You can override default behavior by using this argument.
- Returns:
asyncio.Server object
- Return type:
Server
Classes¶
- exception picows.WSError¶
Bases:
ExceptionBase exception type for websocket-specific exceptions raised by picows.
- exception picows.WSHandshakeError(description, raw_header=None, raw_body=None, response=None)¶
Bases:
WSErrorRaised by
ws_connectwhen websocket HTTP upgrade negotiation fails.- Parameters:
description (str)
raw_header (bytes | None)
raw_body (bytes | None)
response (WSUpgradeResponse | None)
- exception picows.WSInvalidMessageError(
- description,
- raw_header=None,
- raw_body=None,
- response=None,
Bases:
WSHandshakeErrorRaised when the HTTP handshake request or response is malformed.
- Parameters:
description (str)
raw_header (bytes | None)
raw_body (bytes | None)
response (WSUpgradeResponse | None)
- exception picows.WSInvalidStatusError(description, raw_header=None, raw_body=None, response=None)¶
Bases:
WSHandshakeErrorRaised when the HTTP handshake response status rejects the WebSocket upgrade.
- Parameters:
description (str)
raw_header (bytes | None)
raw_body (bytes | None)
response (WSUpgradeResponse | None)
- exception picows.WSInvalidHeaderError(
- description,
- name,
- value=None,
- raw_header=None,
- raw_body=None,
- response=None,
Bases:
WSHandshakeErrorRaised when a HTTP header in the WebSocket handshake is invalid.
- Parameters:
description (str)
name (str)
value (str | None)
raw_header (bytes | None)
raw_body (bytes | None)
response (WSUpgradeResponse | None)
- exception picows.WSInvalidUpgradeError(
- description,
- name,
- value=None,
- raw_header=None,
- raw_body=None,
- response=None,
Bases:
WSInvalidHeaderErrorRaised when Upgrade / Connection headers are invalid in the WebSocket handshake.
- Parameters:
description (str)
name (str)
value (str | None)
raw_header (bytes | None)
raw_body (bytes | None)
response (WSUpgradeResponse | None)
- exception picows.WSProtocolError(code, message)¶
Bases:
WSErrorRaised when receiving or sending frames that break the protocol or violates max_frame_size limit.
Before raising this exception picows send CLOSE frame with error code and initiate disconnect.
- Parameters:
code (Any)
message (Any)
- exception picows.WSInvalidURL(url, msg)¶
Bases:
WSErrorRaised by
ws_connectwhen connecting to an URL that isn’t a valid WebSocket URL.- Parameters:
url (str)
msg (str)
- Return type:
None
- class picows.WSParsedURL¶
- url: str¶
Original URL that was used to construct this object
- scheme: str¶
- is_secure: bool¶
- host: WSHost¶
- port: WSPort¶
- netloc: str¶
- path: str¶
- query: str¶
May be empty if the URL doesn’t include a query component.
- username: str | None¶
- password: str | None¶
- class picows.WSFrame¶
Received websocket frame.
Danger
Only use WSFrame object during
WSListener.on_ws_framecallback. WSFrame objects are essentially just pointers to the underlying receiving buffer. AfterWSListener.on_ws_framehas completed the buffer will be reused for the new incoming data.In order to actually copy payload use one of the get_* methods.
- fin: bool¶
Indicates whether this is the last frame of the message. Websocket messages MAY consist of multiple frames.
Unfragmented message:
WSFrame(msg_type=WSMsgType.<actual message type>, fin=True)
Fragmented message:
WSFrame(msg_type=WSMsgType.<actual message type>, fin=False) WSFrame(msg_type=WSMsgType.CONTINUATION, fin=False) ... # the last frame of the message WSFrame(msg_type=WSMsgType.CONTINUATION, fin=True)
- rsv1: bool¶
Indicates whether rsv1 flag is set in the frame. Some protocol extensions use this flag to indicate that the frame data is compressed. For example in permessage_deflate extension
- rsv2: bool¶
Indicates whether rsv2 flag is set in the frame. Protocol extensions can use this flag.
- rsv3: bool¶
Indicates whether rsv3 flag is set in the frame. Protocol extensions can use this flag.
- last_in_buffer: bool¶
Indicates whether this is the last available frame in the receiving buffer. The receiving buffer may contain more available data, but not the full frame yet.
- tail_size: int¶
Indicates how many bytes are in the receiving buffer after the current frame.
- payload_ptr: char*¶
Available only from Cython.
Raw pointer to the beginning of the frame payload in the receiving buffer. It is safe to pass this pointer with size to SIMD libraries like simdjson. picows guarantees to have just a little bit of extra space behind payload to make sure that SIMD read instructions don’t hit access violation.
- payload_size: size_t¶
Size of the payload.
- get_close_code()¶
- Returns:
This method is only valid for WSMsgType.CLOSE frames.
- get_close_message()¶
- Returns:
a new bytes object with a close message. If there is no close message then returns None.
This method is only valid for WSMsgType.CLOSE frames.
- get_close_reason()¶
- Returns:
a new str object with a close reason. If there is no close reason then returns None.
This method is only valid for WSMsgType.CLOSE frames.
- get_payload_as_ascii_text()¶
- Returns:
a new str object with a copy of frame payload.
This method will throw if payload does not contain valid ASCII 7 text.
This method does not cache results. Payload is copied and a new str object is created every time this method is called.
- get_payload_as_bytes()¶
- Returns:
a new bytes object with a copy of frame payload.
This method does not cache results. Payload is copied and a new bytes object is created every time this method is called.
- get_payload_as_memoryview()¶
- Returns:
continous memoryview to a parser buffer with payload.
Danger
Returned memoryview does NOT own the underlying memory. The content will be invalidated after
WSListener.on_ws_framehas completed. Please process payload or copy it as soon as possible.
- get_payload_as_utf8_text()¶
- Returns:
a new str object with a copy of frame payload.
This method will throw if payload does not contain valid UTF8 text.
This method does not cache results. Payload is copied and a new str object is created every time this method is called.
- class picows.WSUpgradeRequest¶
- method: bytes¶
Request method. b”GET”, b”POST”, etc
- path: bytes¶
Request path. For example b”/ws”
- version: bytes¶
HTTP version. For example b”HTTP/1.1”
- headers: CIMultiDict[str, str]¶
Request headers. Keys are case-insensitive
- class picows.WSUpgradeResponse¶
- version: bytes¶
HTTP version. For example b”HTTP/1.1”
- status: http.HTTPStatus¶
HTTP response status enum value. For example: HTTPStatus.SWITCHING_PROTOCOLS
- headers: CIMultiDict[str, str]¶
Response headers. Keys are case-insensitive
- body: bytes¶
Optional response body. It can be non-empty in case of errors
- static create_101_response(extra_headers=None)¶
Create 101 Switching Protocols response.
- Parameters:
extra_headers (Mapping[str, str] | Iterable[tuple[str, str]] | None) – optional additional headers
- Returns:
a new WSUpgradeResponse object
- Return type:
Any
- static create_error_response(status, body=None, extra_headers=None)¶
Create an upgrade response with an error.
- Parameters:
status (int | HTTPStatus) – int status code or http.HTTPStatus enum value
body (bytes | None) – optional bytes-like response body
extra_headers (Mapping[str, str] | Iterable[tuple[str, str]] | None) – optional additional headers
- Returns:
a new WSUpgradeResponse object
- Return type:
Any
- static create_redirect_response(status, location, extra_headers=None)¶
Create an upgrade redirect response.
- Parameters:
status (int | HTTPStatus) – int status code or http.HTTPStatus enum value
location (str) – redirect target URL
extra_headers (Mapping[str, str] | Iterable[tuple[str, str]] | None) – optional additional headers
- Returns:
a new WSUpgradeResponse object
- Return type:
Any
- class picows.WSUpgradeResponseWithListener(response, listener)¶
Bind
WSUpgradeResponseandWSListenerobjects together.- Parameters:
response (WSUpgradeResponse)
listener (Any)
- class picows.WSListener¶
Base class for user handlers.
All on_ws_* methods receive transport as a first argument for convenience. It is guaranteed that passed transport object is always the same for the same connection.
- is_user_specific_pong(frame)¶
Called before
WSListener.on_ws_frameif auto ping is enabled and pong is expected.User can override this method to indicate that the received frame is a valid response to a previously sent user specific ping message.
The default implementation just do:
def is_user_specific_pong(self, frame: picows.WSFrame) return frame.msg_type == WSMsgType.PONG
- Returns:
Returns True if the frame is a response to a previously send ping. In such case the frame will be consumed by the protocol, i.e
WSListener.on_ws_framewill not be called for this frame.
- on_ws_connected(transport)¶
Called after websocket handshake is complete and websocket is ready to send and receive frames. Initiate disconnect if exception is thrown by user handler.
client side: the exception will be transferred to and reraised by
wait_disconnected.server side: the exception will be ‘swallowed’ by the library and logged at the ERROR level.
- Parameters:
transport –
WSTransportobject
- on_ws_disconnected(transport)¶
Called when websocket has been disconnected.
- Parameters:
transport –
WSTransport
- on_ws_frame(transport, frame)¶
Called when a new frame is received.
Initiate disconnect if exception is thrown by user handler and disconnect_on_exception was set to True in
ws_connectorws_create_server. In such case:client side: the exception will be transferred to and reraised by
wait_disconnected.server side: the exception will be ‘swallowed’ by the library and logged at the ERROR level.
Danger
WSFrame is essentially just a pointer to a chunk of memory in the receiving buffer. It does not own the memory. Do NOT cache or store WSFrame object for later processing because the data may be invalidated after
WSListener.on_ws_frameis complete. Process the payload immediately or just copy it with one of WSFrame.get_* methods.- Parameters:
transport –
WSTransportobjectframe –
WSFrameobject
- pause_writing()¶
Called when the underlying transport’s buffer goes over the high watermark. This is a purely informative callback. You can ignore it and just keep writing. The data will be queued and eventually send anyway.
- resume_writing()¶
Called when the underlying transport’s buffer drains below the low watermark.
- send_user_specific_ping(transport)¶
Called when the auto-ping logic wants to send a ping to a remote peer.
User can override this method to send something else instead of the standard PING frame.
Default implementation:
def send_user_specific_ping(self, transport: picows.WSTransport) return transport.send_ping()
- Parameters:
transport –
WSTransport
- class picows.WSTransport¶
Note
All send methods never block. The data is buffered and arranged to be sent out asynchronously in case if it cannot be sent immediately. This behavior is derived from the underlying asyncio.WriteTransport.write Once
WSTransport.send_closeis called,WSTransport.is_close_frame_sentbecomesTrueand any subsequent send calls are no-ops (they do nothing).- underlying_transport: asyncio.Transport¶
Underlying TCP or SSL transport. Can be used to set buffer limits, check connection state, etc.
Note
Please don’t use it to send data. Use only WSTransport.send methods to send frames.
- is_close_frame_sent: bool¶
Indicates whether a CLOSE frame has already been sent with
WSTransport.send_close.When this flag is
True, subsequent calls to send methods (WSTransport.send,WSTransport.send_ping,WSTransport.send_pong, andWSTransport.send_close) are no-ops and do nothing.
- is_disconnected: bool¶
Indicates whether the underlying asyncio transport has reported connection_lost event.
WSTransport.send_close.When this flag is
True, subsequent calls to send methods (WSTransport.send,WSTransport.send_ping,WSTransport.send_pong, andWSTransport.send_close) are no-ops and do nothing.
- request: WSUpgradeRequest¶
Opening handshake request.
- response: WSUpgradeResponse¶
Opening handshake response.
- send_reuse_external_buffer(
- WSMsgType msg_type,
- char* msg_ptr,
- size_t msg_size,
- bint fin=True,
- bint rsv1=False,
- bint rsv2=False,
- bint rsv3=False,
Available only from Cython.
Send a frame over websocket with a message as its payload. This function does not copy message to prepare websocket frames. It reuses the message’s memory and writes a WebSocket header at the front.
Attention
The message buffer should have at least 14 writable bytes in front of the message pointer.
- Parameters:
msg_type – Message type
msg_ptr – Pointer to a message payload
msg_size – Size of the message payload
fin – fin bit in websocket frame. Indicates that the frame is the last one in the message.
rsv1 – first reserved bit in websocket frame. Some protocol extensions use it to indicate that payload is compressed.
rsv2 – second reserved bit in websocket frame. Protocol extensions can use this flag.
rsv3 – third reserved bit in websocket frame. Protocol extensions can use this flag.
- disconnect(graceful=True)¶
Close the underlying transport.
It is safe to call this method multiple times. It does nothing if the transport is already closed.
- Parameters:
graceful – If True then send any remaining outgoing data in the buffer before closing the socket. This may potentially significantly delay on_ws_disconnected event since OS may wait for TCP_ACK for the data that was previously sent and until OS ack timeout fires up the socket will remain in connected state.
- async measure_roundtrip_time(rounds)¶
Coroutine that measures roundtrip time by running ping-pong.
- Parameters:
rounds – how many ping-pong rounds to do
- Returns:
list of measured roundtrip times
- Return type:
list[float]
- notify_user_specific_pong_received()¶
Notify the auto-ping loop that a user-specific pong message has been received.
This method is useful when determining whether a frame contains a user-specific pong is too expensive for is_user_specific_pong (for example, it may require full JSON parsing). In such cases,
WSListener.is_user_specific_pongshould always return False, and the logic inWSListener.on_ws_frameshould callWSTransport.notify_user_specific_pong_received.It is safe to call this method even if auto-ping is disabled or the auto-ping loop doesn’t expect pong messages. In such cases, the method simply does nothing.
- send(
- msg_type,
- message,
- fin=True,
- rsv1=False,
- rsv2=False,
- rsv3=False,
Send a frame over websocket with a message as its payload.
Please note that this function has to copy the whole message into library’s write buffer in order to be able to prepend websocket frame header and apply mask to the whole message. If you want to avoid copying please use
WSTransport.send_reuse_external_bytearrayorWSTransport.send_reuse_external_buffer.- Parameters:
msg_type –
WSMsgTypeenum valuemessage – an optional bytes-like object
fin – fin bit in websocket frame. Indicate that the frame is the last one in the message.
rsv1 – first reserved bit in websocket frame. Some protocol extensions use it to indicate that payload is compressed.
rsv2 – second reserved bit in websocket frame. Protocol extensions can use this flag.
rsv3 – third reserved bit in websocket frame. Protocol extensions can use this flag.
- send_close(close_code=<WSCloseCode.NO_INFO: 0>, close_message=None)¶
Send a CLOSE control frame with an optional message. This method doesn’t disconnect the underlying transport. Does nothing if the underlying transport is already disconnected.
- Parameters:
close_code –
WSCloseCodevalueclose_message – an optional bytes-like object
- send_ping(message=None)¶
Send a PING control frame with an optional message.
- Parameters:
message – an optional bytes-like object
- send_pong(message=None)¶
Send a PONG control frame with an optional message.
- Parameters:
message – an optional bytes-like object
- send_reuse_external_bytearray(
- msg_type,
- buffer,
- msg_offset,
- fin=True,
- rsv1=False,
- rsv2=False,
- rsv3=False,
Send a frame over websocket with a message as its payload. This function does not copy message to prepare websocket frames. It reuses bytearray’s memory to write websocket frame header at the front.
- Parameters:
msg_type –
WSMsgTypeenum value, except CLOSE. Use send_close to send close frames.msg_offset – specifies where message begins in the bytearray. Must be at least 14 to let picows to write websocket frame header in front of the message.
buffer – bytearray that contains message and some extra space (at least 14 bytes) in the beginning. The len of the message is determined as len(buffer) - msg_offset
fin – fin bit in websocket frame. Indicate that the frame is the last one in the message.
rsv1 – first reserved bit in websocket frame. Some protocol extensions use it to indicate that payload is compressed.
rsv2 – second reserved bit in websocket frame. Protocol extensions can use this flag.
rsv3 – third reserved bit in websocket frame. Protocol extensions can use this flag.
- async wait_disconnected()¶
Wait until websocket is fully disconnected.
Completion means:
the underlying transport is closed
WSListener.on_ws_disconnectedcallback has finished
Exception behavior:
If a user
WSListener.on_ws_*callback raises and this causes picows to disconnect, the original exception is transferred here and re-raised by this coroutine when awaited. In this case picows sends a CLOSE frame withWSCloseCode.INTERNAL_ERRORand disconnects.User code may raise
WSProtocolErrorfrom anWSListener.on_ws_*callback to choose the CLOSE frame code and reason.Protocol violations detected by picows may also be re-raised here.
Peer-initiated disconnects do not cause this coroutine to raise by themselves, even if the peer sends a non-OK CLOSE code or drops the connection without sending a CLOSE frame.
In general, this coroutine raises when picows detected a local failure that caused the disconnect. Remote-side shutdown conditions are exposed through connection state such as
close_handshake, not by raising from this coroutine.This coroutine internally shields the wait future, so cancelling the waiter does not cancel internal disconnect bookkeeping.
Enums¶
- enum picows.WSMsgType(value)¶
- Member Type:
int
Valid values are as follows:
- CONTINUATION = <WSMsgType.CONTINUATION: 0>¶
- TEXT = <WSMsgType.TEXT: 1>¶
- BINARY = <WSMsgType.BINARY: 2>¶
- PING = <WSMsgType.PING: 9>¶
- PONG = <WSMsgType.PONG: 10>¶
- CLOSE = <WSMsgType.CLOSE: 8>¶
- enum picows.WSCloseCode(value)¶
- Member Type:
int
Valid values are as follows:
- NO_INFO = <WSCloseCode.NO_INFO: 0>¶
- OK = <WSCloseCode.OK: 1000>¶
- GOING_AWAY = <WSCloseCode.GOING_AWAY: 1001>¶
- PROTOCOL_ERROR = <WSCloseCode.PROTOCOL_ERROR: 1002>¶
- UNSUPPORTED_DATA = <WSCloseCode.UNSUPPORTED_DATA: 1003>¶
- ABNORMAL_CLOSURE = <WSCloseCode.ABNORMAL_CLOSURE: 1006>¶
- INVALID_TEXT = <WSCloseCode.INVALID_TEXT: 1007>¶
- POLICY_VIOLATION = <WSCloseCode.POLICY_VIOLATION: 1008>¶
- MESSAGE_TOO_BIG = <WSCloseCode.MESSAGE_TOO_BIG: 1009>¶
- MANDATORY_EXTENSION = <WSCloseCode.MANDATORY_EXTENSION: 1010>¶
- INTERNAL_ERROR = <WSCloseCode.INTERNAL_ERROR: 1011>¶
- SERVICE_RESTART = <WSCloseCode.SERVICE_RESTART: 1012>¶
- TRY_AGAIN_LATER = <WSCloseCode.TRY_AGAIN_LATER: 1013>¶
- BAD_GATEWAY = <WSCloseCode.BAD_GATEWAY: 1014>¶