mirror of
https://github.com/django/daphne.git
synced 2024-11-25 09:13:44 +03:00
Support websocket options for cli and infinite time to timeouts (#99)
* add websocket timeout and websocket connetion timeout to Cli. Add support for infinite time to websocket timeout and websocket connection timeout * change test
This commit is contained in:
parent
d68461920f
commit
9f4f057e4c
|
@ -36,6 +36,18 @@ class CommandLineInterface(object):
|
|||
help='The host/address to bind to',
|
||||
default=None,
|
||||
)
|
||||
self.parser.add_argument(
|
||||
'--websocket_timeout',
|
||||
type=int,
|
||||
help='max time websocket connected. -1 to infinite.',
|
||||
default=None,
|
||||
)
|
||||
self.parser.add_argument(
|
||||
'--websocket_connect_timeout',
|
||||
type=int,
|
||||
help='max time to refuse establishing connection. -1 to infinite',
|
||||
default=None,
|
||||
)
|
||||
self.parser.add_argument(
|
||||
'-u',
|
||||
'--unix-socket',
|
||||
|
@ -186,6 +198,8 @@ class CommandLineInterface(object):
|
|||
http_timeout=args.http_timeout,
|
||||
ping_interval=args.ping_interval,
|
||||
ping_timeout=args.ping_timeout,
|
||||
websocket_timeout=args.websocket_timeout,
|
||||
websocket_connect_timeout=args.websocket_connect_timeout,
|
||||
action_logger=AccessLogGenerator(access_log_stream) if access_log_stream else None,
|
||||
ws_protocols=args.ws_protocols,
|
||||
root_path=args.root_path,
|
||||
|
|
|
@ -385,7 +385,7 @@ class HTTPFactory(http.HTTPFactory):
|
|||
# WebSocket timeout checking and keepalive ping sending
|
||||
elif isinstance(protocol, WebSocketProtocol):
|
||||
# Timeout check
|
||||
if protocol.duration() > self.websocket_timeout:
|
||||
if protocol.duration() > self.websocket_timeout and self.websocket_timeout >= 0:
|
||||
protocol.serverClose()
|
||||
# Ping check
|
||||
else:
|
||||
|
|
|
@ -25,6 +25,7 @@ class Server(object):
|
|||
action_logger=None,
|
||||
http_timeout=120,
|
||||
websocket_timeout=None,
|
||||
websocket_connect_timeout=None,
|
||||
ping_interval=20,
|
||||
ping_timeout=30,
|
||||
ws_protocols=None,
|
||||
|
@ -72,6 +73,7 @@ class Server(object):
|
|||
self.action_logger,
|
||||
timeout=self.http_timeout,
|
||||
websocket_timeout=self.websocket_timeout,
|
||||
websocket_connect_timeout=self.websocket_connect_timeout,
|
||||
ping_interval=self.ping_interval,
|
||||
ping_timeout=self.ping_timeout,
|
||||
ws_protocols=self.ws_protocols,
|
||||
|
|
Loading…
Reference in New Issue
Block a user