Thank you Andrew for your answer! Nicolas
On Wednesday, February 28, 2018 at 12:05:09 AM UTC+1, Andrew Godwin wrote: > > 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 <[email protected] > <javascript:>> 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 [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> 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 >> >> <https://groups.google.com/d/msgid/django-users/160e0c3b-c74e-4683-acf6-a882716b9c5b%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> 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 [email protected]. To post to this group, send email to [email protected]. 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/b1857c50-b1e7-48ef-b005-923f4b9795a4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

