Skip to content

Commit

Permalink
[change] Added variable to configure daphne websocket timeout
Browse files Browse the repository at this point in the history
This timeout value is also used for configuring the "group_expiry"
of CHANNEL_LAYERS.
  • Loading branch information
pandafy committed Dec 15, 2021
1 parent f36b320 commit 109f5bd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,8 @@ Below are listed all the variables you can customize (you may also want to take
openwisp2_uwsgi_threads: 2
# number of daphne process to spawn. Default value is 1
openwisp2_daphne_processes: 2
# maximum time to allow a websocket to be connected (in seconds)
openwisp2_daphne_websocket_timeout: 1800
# the following setting controls which ip address range
# is allowed to access the openwisp2 admin web interface
# (by default any IP is allowed)
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ postfix_smtpd_relay_restrictions_override: "permit_sasl_authenticated, permit_my
openwisp2_uwsgi_processes: 1
openwisp2_uwsgi_threads: 1
openwisp2_daphne_processes: 1
openwisp2_daphne_websocket_timeout: 3600 # in seconds
# internationalization
openwisp2_internationalization: false
openwisp2_users_auth_api: true
Expand Down
5 changes: 4 additions & 1 deletion templates/openwisp2/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {'hosts': [('{{ openwisp2_redis_host }}', {{ openwisp2_redis_port }})]},
'CONFIG': {
'hosts': [('{{ openwisp2_redis_host }}', {{ openwisp2_redis_port }})],
'group_expiry': {{ openwisp2_daphne_websocket_timeout }},
},
},
}
ASGI_APPLICATION = 'openwisp2.routing.application'
Expand Down
2 changes: 1 addition & 1 deletion templates/supervisor/daphne.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
user={{ www_user }}
socket=unix://{{ openwisp2_path }}/daphne0.sock
directory={{ openwisp2_path }}
command={{ openwisp2_path }}/env/bin/daphne --fd 0 -u {{ openwisp2_path }}/daphne%(process_num)d.sock --access-log - --proxy-headers openwisp2.asgi:application
command={{ openwisp2_path }}/env/bin/daphne --fd 0 -u {{ openwisp2_path }}/daphne%(process_num)d.sock --access-log - --websocket_timeout {{ openwisp2_daphne_websocket_timeout }} --proxy-headers openwisp2.asgi:application
process_name=asgi%(process_num)d
numprocs={{ openwisp2_daphne_processes }}
autostart=true
Expand Down

0 comments on commit 109f5bd

Please sign in to comment.