1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
Features
========
.. currentmodule:: websockets
Feature support matrices summarize which implementations support which features.
.. raw:: html
<style>
.support-matrix-table { width: 100%; }
.support-matrix-table th:first-child { text-align: left; }
.support-matrix-table th:not(:first-child) { text-align: center; width: 15%; }
.support-matrix-table td:not(:first-child) { text-align: center; }
</style>
.. |aio| replace:: :mod:`asyncio` (new)
.. |sync| replace:: :mod:`threading`
.. |sans| replace:: `Sans-I/O`_
.. |leg| replace:: :mod:`asyncio` (legacy)
.. _Sans-I/O: https://sans-io.readthedocs.io/
Both sides
----------
.. table::
:class: support-matrix-table
+------------------------------------+--------+--------+--------+--------+
| | |aio| | |sync| | |sans| | |leg| |
+====================================+========+========+========+========+
| Perform the opening handshake | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Enforce opening timeout | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Send a message | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Broadcast a message | ✅ | ❌ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Receive a message | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Iterate over received messages | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Send a fragmented message | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Receive a fragmented message frame | ✅ | ✅ | — | ❌ |
| by frame | | | | |
+------------------------------------+--------+--------+--------+--------+
| Receive a fragmented message after | ✅ | ✅ | — | ✅ |
| reassembly | | | | |
+------------------------------------+--------+--------+--------+--------+
| Force sending a message as Text or | ✅ | ✅ | — | ❌ |
| Binary | | | | |
+------------------------------------+--------+--------+--------+--------+
| Force receiving a message as | ✅ | ✅ | — | ❌ |
| :class:`bytes` or :class:`str` | | | | |
+------------------------------------+--------+--------+--------+--------+
| Send a ping | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Respond to pings automatically | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Send a pong | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Keepalive | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Heartbeat | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Measure latency | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Perform the closing handshake | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Enforce closing timeout | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Report close codes and reasons | ✅ | ✅ | ✅ | ❌ |
| from both sides | | | | |
+------------------------------------+--------+--------+--------+--------+
| Compress messages (:rfc:`7692`) | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Tune memory usage for compression | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Negotiate extensions | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Implement custom extensions | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Negotiate a subprotocol | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Enforce security limits | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Log events | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
Server
------
.. table::
:class: support-matrix-table
+------------------------------------+--------+--------+--------+--------+
| | |aio| | |sync| | |sans| | |leg| |
+====================================+========+========+========+========+
| Listen on a TCP socket | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Listen on a Unix socket | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Listen using a preexisting socket | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Encrypt connection with TLS | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Close server on context exit | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Close connection on handler exit | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Shut down server gracefully | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Check ``Origin`` header | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Customize subprotocol selection | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Configure ``Server`` header | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Alter opening handshake request | ✅ | ✅ | ✅ | ❌ |
+------------------------------------+--------+--------+--------+--------+
| Alter opening handshake response | ✅ | ✅ | ✅ | ❌ |
+------------------------------------+--------+--------+--------+--------+
| Force an HTTP response | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Perform HTTP Basic Authentication | ✅ | ✅ | ❌ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Dispatch connections to handlers | ✅ | ✅ | — | ❌ |
+------------------------------------+--------+--------+--------+--------+
Client
------
.. table::
:class: support-matrix-table
+------------------------------------+--------+--------+--------+--------+
| | |aio| | |sync| | |sans| | |leg| |
+====================================+========+========+========+========+
| Connect to a TCP socket | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Connect to a Unix socket | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Connect using a preexisting socket | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Encrypt connection with TLS | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Close connection on context exit | ✅ | ✅ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Reconnect automatically | ✅ | ❌ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Configure ``Origin`` header | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Configure ``User-Agent`` header | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Modify opening handshake request | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Modify opening handshake response | ✅ | ✅ | ✅ | ❌ |
+------------------------------------+--------+--------+--------+--------+
| Connect to non-ASCII IRIs | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Follow HTTP redirects | ✅ | ❌ | — | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Perform HTTP Basic Authentication | ✅ | ✅ | ✅ | ✅ |
+------------------------------------+--------+--------+--------+--------+
| Connect via HTTP proxy | ✅ | ✅ | — | ❌ |
+------------------------------------+--------+--------+--------+--------+
| Connect via SOCKS5 proxy | ✅ | ✅ | — | ❌ |
+------------------------------------+--------+--------+--------+--------+
Known limitations
-----------------
There is no way to control compression of outgoing frames on a per-frame basis
(`#538`_). If compression is enabled, all frames are compressed.
.. _#538: https://github.com/python-websockets/websockets/issues/538
The server doesn't check the Host header and doesn't respond with HTTP 400 Bad
Request if it is missing or invalid (`#1246`_).
.. _#1246: https://github.com/python-websockets/websockets/issues/1246
The client doesn't support HTTP Digest Authentication (`#784`_).
.. _#784: https://github.com/python-websockets/websockets/issues/784
The client API doesn't attempt to guarantee that there is no more than one
connection to a given IP address in a CONNECTING state. This behavior is
mandated by :rfc:`6455`, section 4.1. However, :func:`~asyncio.client.connect()`
isn't the right layer for enforcing this constraint. It's the caller's
responsibility.
It is possible to send or receive a text message containing invalid UTF-8 with
``send(not_utf8_bytes, text=True)`` and ``not_utf8_bytes = recv(decode=False)``
respectively. As a side effect of disabling UTF-8 encoding and decoding, these
options also disable UTF-8 validation.
|