requeue websocket messages that don't (yet) have an established user

There's a race between our `ws_connect` and `ws_receive` methods;
it's possible to fall into a scenario where we're handling a legitimate
message *before* django-channels is able to persist the `user_id` into
the channel session.  This results in a scenario where a user can open
a browser tab and never receive new websocket messages.  In this
scenario, we should just toss the message back into the queue and try
again later (up to a reasonable limit of retries).
This commit is contained in:
Ryan Petrello
2017-02-28 09:34:44 -05:00
parent cdb757503e
commit 45819f6b9a
2 changed files with 16 additions and 2 deletions

View File

@@ -866,6 +866,11 @@ TOWER_SETTINGS_MANIFEST = {}
LOG_AGGREGATOR_ENABLED = False
# The number of retry attempts for websocket session establishment
# If you're encountering issues establishing websockets in clustered Tower,
# raising this value can help
CHANNEL_LAYER_RECEIVE_MAX_RETRY = 10
# Logging configuration.
LOGGING = {
'version': 1,