Yes, there is one session made per connection. They should expire and get cleaned up like normal HTTP sessions if you run the session cleanup in Django (or use backends that auto-cleanup)
Andrew
On Tue, Feb 27, 2018 at 11:00 AM, nferrari <ferrari.nicolas@gmail.com> wrote:
Hello,--
I'm using django-channels for some months and I'm observing a behaviour for which I don't know if it's a normal one, or a misconfiguration from my side.
Here is my pretty simple consumer :
# Connected to websocket.connect
@channel_session_user_from_http
def ws_task_connect(message):
if isinstance(message.user, AnonymousUser):
message.reply_channel.send({"close" : True})
else:
# Accept connection
message.reply_channel.send({"accept" : True})
# Add them to the right group
Group("task-%d" % message.user.pk).add(message.reply_channel )
refresh_current_tasks(message.user , send_if_empty=False)
# Connected to websocket.disconnect
@enforce_ordering
@channel_session_user
def ws_task_disconnect(message):
Group("task-%d" % message.user.pk).discard(message .reply_channel)
It does work but if my user does refresh the page, I see a new entry in the session table (django_session). In other terms, if my user browse 20 different pages in his administration panel, I'll have 21 entries in the django_session table (1 session created by the native Django SessionMiddleware, 20 for every WebSocket created by browsing the 20 pages). Is it normal or shouldn't this by reduced to 2 entries?
For information, upgrading to django-channels 2 is not yet an option for this project.
Kind regards,
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com .
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/160e0c3b- .c74e-4683-acf6-a882716b9c5b% 40googlegroups.com
For more options, visit https://groups.google.com/d/optout .
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFwN1uqkAFROigauWNObxvkYd5cEvhYRDAYt2Ut8HNbcshTf_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment