mirror of
https://github.com/django/daphne.git
synced 2024-11-29 11:13:43 +03:00
Added websocket_handshake_timeout option/server param
Added an optional parameter to Server and HTTPFactory to allow Autobahn openHandshakeTimeout to be overridden.
This commit is contained in:
parent
4ff2384337
commit
c5385fb253
|
@ -308,7 +308,7 @@ class HTTPFactory(http.HTTPFactory):
|
||||||
routed appropriately.
|
routed appropriately.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, channel_layer, action_logger=None, send_channel=None, timeout=120, websocket_timeout=86400, ping_interval=20, ping_timeout=30, ws_protocols=None, root_path="", websocket_connect_timeout=30, proxy_forwarded_address_header=None, proxy_forwarded_port_header=None):
|
def __init__(self, channel_layer, action_logger=None, send_channel=None, timeout=120, websocket_timeout=86400, ping_interval=20, ping_timeout=30, ws_protocols=None, root_path="", websocket_connect_timeout=30, proxy_forwarded_address_header=None, proxy_forwarded_port_header=None, websocket_handshake_timeout=5):
|
||||||
http.HTTPFactory.__init__(self)
|
http.HTTPFactory.__init__(self)
|
||||||
self.channel_layer = channel_layer
|
self.channel_layer = channel_layer
|
||||||
self.action_logger = action_logger
|
self.action_logger = action_logger
|
||||||
|
@ -327,6 +327,7 @@ class HTTPFactory(http.HTTPFactory):
|
||||||
self.ws_factory.setProtocolOptions(
|
self.ws_factory.setProtocolOptions(
|
||||||
autoPingTimeout=ping_timeout,
|
autoPingTimeout=ping_timeout,
|
||||||
allowNullOrigin=True,
|
allowNullOrigin=True,
|
||||||
|
openHandshakeTimeout=websocket_handshake_timeout
|
||||||
)
|
)
|
||||||
self.ws_factory.protocol = WebSocketProtocol
|
self.ws_factory.protocol = WebSocketProtocol
|
||||||
self.ws_factory.reply_protocols = self.reply_protocols
|
self.ws_factory.reply_protocols = self.reply_protocols
|
||||||
|
|
|
@ -37,7 +37,8 @@ class Server(object):
|
||||||
proxy_forwarded_address_header=None,
|
proxy_forwarded_address_header=None,
|
||||||
proxy_forwarded_port_header=None,
|
proxy_forwarded_port_header=None,
|
||||||
force_sync=False,
|
force_sync=False,
|
||||||
verbosity=1
|
verbosity=1,
|
||||||
|
websocket_handshake_timeout=5
|
||||||
):
|
):
|
||||||
self.channel_layer = channel_layer
|
self.channel_layer = channel_layer
|
||||||
self.endpoints = endpoints or []
|
self.endpoints = endpoints or []
|
||||||
|
@ -69,6 +70,7 @@ class Server(object):
|
||||||
# channel layer's group_expiry value if present, or one day if not.
|
# channel layer's group_expiry value if present, or one day if not.
|
||||||
self.websocket_timeout = websocket_timeout or getattr(channel_layer, "group_expiry", 86400)
|
self.websocket_timeout = websocket_timeout or getattr(channel_layer, "group_expiry", 86400)
|
||||||
self.websocket_connect_timeout = websocket_connect_timeout
|
self.websocket_connect_timeout = websocket_connect_timeout
|
||||||
|
self.websocket_handshake_timeout = websocket_handshake_timeout
|
||||||
self.ws_protocols = ws_protocols
|
self.ws_protocols = ws_protocols
|
||||||
self.root_path = root_path
|
self.root_path = root_path
|
||||||
self.force_sync = force_sync
|
self.force_sync = force_sync
|
||||||
|
@ -92,7 +94,8 @@ class Server(object):
|
||||||
ws_protocols=self.ws_protocols,
|
ws_protocols=self.ws_protocols,
|
||||||
root_path=self.root_path,
|
root_path=self.root_path,
|
||||||
proxy_forwarded_address_header=self.proxy_forwarded_address_header,
|
proxy_forwarded_address_header=self.proxy_forwarded_address_header,
|
||||||
proxy_forwarded_port_header=self.proxy_forwarded_port_header
|
proxy_forwarded_port_header=self.proxy_forwarded_port_header,
|
||||||
|
websocket_handshake_timeout=self.websocket_handshake_timeout
|
||||||
)
|
)
|
||||||
if self.verbosity <= 1:
|
if self.verbosity <= 1:
|
||||||
# Redirect the Twisted log to nowhere
|
# Redirect the Twisted log to nowhere
|
||||||
|
|
Loading…
Reference in New Issue
Block a user