- Reduced noise in logs caused by connection resets.
- Avoided crashing on concurrent writes on slow connections.
- Avoided a warning when closing a connection before the opening handshake.
- Added flow control for incoming data.
Version 3.0 introduces a backwards-incompatible change in the
If you’re upgrading from 2.x or earlier, please read this carefully.
recv() used to return
None when the connection was closed. This required checking the return
value of every call:
message = await websocket.recv() if message is None: return
Now it raises a
instead. This is more Pythonic. The previous code can be simplified to:
message = await websocket.recv()
When implementing a server, which is the more popular use case, there’s no strong reason to handle such exceptions. Let them bubble up, terminate the handler coroutine, and the server will simply ignore them.
In order to avoid stranding projects built upon an earlier version, the
previous behavior can be restored by passing
documented in their signatures but isn’t scheduled for deprecation either.
connect()can be used as an asynchronous context manager on Python ≥ 3.5.
- Updated documentation with
asyncsyntax from Python 3.5.
pong()supports data passed as
strin addition to
- Worked around an asyncio bug affecting connection termination under load.
state_nameatttribute on protocols a public API.
- Improved documentation.
- Added compatibility with Python 3.5.
- Refreshed documentation.
remote_addressattributes on protocols.
- Closed open connections with code 1001 when a server shuts down.
- Avoided TCP fragmentation of small frames.
- Improved documentation.
- Provided access to handshake request and response HTTP headers.
- Allowed customizing handshake request and response HTTP headers.
- Supported running on a non-default event loop.
- Returned a 403 error code instead of 400 when the request Origin isn’t allowed.
recv()no longer drops the next message.
- Clarified that the closing handshake can be initiated by the client.
- Set the close status code and reason more consistently.
- Strengthened connection termination by simplifying the implementation.
- Improved tests, added tox configuration, and enforced 100% branch coverage.
- Improved compliance of close codes.
- Added support for limiting message size.
secureattributes on protocols.
- Added support for providing and checking Origin.
If you’re upgrading from 1.x or earlier, please read this carefully.
These APIs used to be functions. Now they’re coroutines.
you must now write:
- Added flow control for outgoing data.
- Initial public release.