From 0fe0796870fcb62551a979dc7bcf7b4c20e3e1c2 Mon Sep 17 00:00:00 2001 From: Yun Xu Date: Fri, 9 Feb 2018 20:44:02 -0800 Subject: [PATCH] expose websocket protocol arguments --- sanic/app.py | 2 ++ sanic/config.py | 2 ++ sanic/server.py | 3 +++ 3 files changed, 7 insertions(+) diff --git a/sanic/app.py b/sanic/app.py index 6e8377f5..1513e467 100644 --- a/sanic/app.py +++ b/sanic/app.py @@ -807,6 +807,8 @@ class Sanic: 'access_log': access_log, 'websocket_max_size': self.config.WEBSOCKET_MAX_SIZE, 'websocket_max_queue': self.config.WEBSOCKET_MAX_QUEUE, + 'websocket_read_limit': self.config.WEBSOCKET_READ_LIMIT, + 'websocket_write_limit': self.config.WEBSOCKET_WRITE_LIMIT, 'graceful_shutdown_timeout': self.config.GRACEFUL_SHUTDOWN_TIMEOUT } diff --git a/sanic/config.py b/sanic/config.py index 922a9874..8e1f383c 100644 --- a/sanic/config.py +++ b/sanic/config.py @@ -36,6 +36,8 @@ class Config(dict): self.KEEP_ALIVE_TIMEOUT = 5 # 5 seconds self.WEBSOCKET_MAX_SIZE = 2 ** 20 # 1 megabytes self.WEBSOCKET_MAX_QUEUE = 32 + self.WEBSOCKET_READ_LIMIT = 2 ** 16 + self.WEBSOCKET_WRITE_LIMIT = 2 ** 16 self.GRACEFUL_SHUTDOWN_TIMEOUT = 15.0 # 15 sec if load_env: diff --git a/sanic/server.py b/sanic/server.py index 10a9040a..62193db5 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -514,6 +514,7 @@ def serve(host, port, request_handler, error_handler, before_start=None, connections=None, signal=Signal(), request_class=None, access_log=True, keep_alive=True, is_request_stream=False, router=None, websocket_max_size=None, websocket_max_queue=None, + websocket_read_limit=2 ** 16, websocket_write_limit=2 ** 16, state=None, graceful_shutdown_timeout=15.0): """Start asynchronous HTTP Server on an individual process. @@ -574,6 +575,8 @@ def serve(host, port, request_handler, error_handler, before_start=None, router=router, websocket_max_size=websocket_max_size, websocket_max_queue=websocket_max_queue, + websocket_read_limit=websocket_read_limit, + websocket_write_limit=websocket_write_limit, state=state, debug=debug, )