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