From 580666694918e29fb5b09f2a46653ee29616051f Mon Sep 17 00:00:00 2001 From: Bob Olde Hampsink Date: Thu, 1 Feb 2018 16:23:10 +0100 Subject: [PATCH] Extend WebSocketProtocol arguments to accept all arguments of websockets.protocol.WebSocketCommonProtocol --- sanic/websocket.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sanic/websocket.py b/sanic/websocket.py index bc78c76f..99408af5 100644 --- a/sanic/websocket.py +++ b/sanic/websocket.py @@ -6,12 +6,18 @@ from websockets import ConnectionClosed # noqa class WebSocketProtocol(HttpProtocol): - def __init__(self, *args, websocket_max_size=None, - websocket_max_queue=None, **kwargs): + def __init__(self, *args, websocket_timeout=10, + websocket_max_size=None, + websocket_max_queue=None, + websocket_read_limit=2 ** 16, + websocket_write_limit=2 ** 16, **kwargs): super().__init__(*args, **kwargs) self.websocket = None + self.websocket_timeout = websocket_timeout self.websocket_max_size = websocket_max_size self.websocket_max_queue = websocket_max_queue + self.websocket_read_limit = websocket_read_limit + self.websocket_write_limit = websocket_write_limit # timeouts make no sense for websocket routes def request_timeout_callback(self): @@ -85,8 +91,11 @@ class WebSocketProtocol(HttpProtocol): # hook up the websocket protocol self.websocket = WebSocketCommonProtocol( + timeout=self.websocket_timeout, max_size=self.websocket_max_size, - max_queue=self.websocket_max_queue + max_queue=self.websocket_max_queue, + read_limit=self.websocket_read_limit, + write_limit=self.websocket_write_limit ) self.websocket.subprotocol = subprotocol self.websocket.connection_made(request.transport)