From 134c414fe57c94cdcf0dbd6107fdde1e5f7ac48e Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 2 Oct 2019 07:03:10 +0100 Subject: [PATCH] Support websockets 8.x as well as 7.x (#1687) Sanic currently requires websockets 7.x, but it's straightforward to also support the more recent 8.x. --- sanic/websocket.py | 3 +++ setup.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/sanic/websocket.py b/sanic/websocket.py index 60092836..a2c7b81d 100644 --- a/sanic/websocket.py +++ b/sanic/websocket.py @@ -119,6 +119,9 @@ class WebSocketProtocol(HttpProtocol): read_limit=self.websocket_read_limit, write_limit=self.websocket_write_limit, ) + # Following two lines are required for websockets 8.x + self.websocket.is_client = False + self.websocket.side = "server" self.websocket.subprotocol = subprotocol self.websocket.connection_made(request.transport) self.websocket.connection_open() diff --git a/setup.py b/setup.py index 9d278fbf..5c60d087 100644 --- a/setup.py +++ b/setup.py @@ -80,7 +80,7 @@ requirements = [ uvloop, ujson, "aiofiles>=0.3.0", - "websockets>=7.0,<8.0", + "websockets>=7.0,<9.0", "multidict>=4.0,<5.0", "requests-async==0.5.0", ]