Skip to content

Commit

Permalink
maint: enable websocket_ping_interval by default in tornado server
Browse files Browse the repository at this point in the history
  • Loading branch information
wang0618 committed Oct 12, 2021
1 parent fa429c7 commit 4bc0a2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pywebio/platform/path_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ def path_deploy(base, port=0, host='',
"""

utils.MAX_PAYLOAD_SIZE = max_payload_size = parse_file_size(max_payload_size)
# Since some cloud server may close idle connections (such as heroku),
# use `websocket_ping_interval` to keep the connection alive
tornado_app_settings.setdefault('websocket_ping_interval', 30)
tornado_app_settings.setdefault('websocket_max_message_size', max_payload_size) # Backward compatible
tornado_app_settings['websocket_max_message_size'] = parse_file_size(tornado_app_settings['websocket_max_message_size'])
gen = _path_deploy(base, port=port, host=host,
Expand Down
3 changes: 3 additions & 0 deletions pywebio/platform/tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ def start_server(applications, port=0, host='',

utils.MAX_PAYLOAD_SIZE = max_payload_size = parse_file_size(max_payload_size)

# Since some cloud server may close idle connections (such as heroku),
# use `websocket_ping_interval` to keep the connection alive
tornado_app_settings.setdefault('websocket_ping_interval', 30)
tornado_app_settings.setdefault('websocket_max_message_size', max_payload_size) # Backward compatible
tornado_app_settings['websocket_max_message_size'] = parse_file_size(
tornado_app_settings['websocket_max_message_size'])
Expand Down

0 comments on commit 4bc0a2d

Please sign in to comment.