It sounds like you're doing the right thing - storing reply channel names and sending to them from a background process - so I think the problem must be in the channel layer configuration.
Have you confirmed the background task has the same Django settings? Have you tried monitoring the redis server to see if messages actually get sent to it? (You'll see an RPUSH command for that).
Andrew
On 28 Jan 2018 08:14, "Arne Wieding" <arne.wieding@gmail.com> wrote:
Hi there,--i have implemented django channels into my project to turn an intensive data importing task into a background task. This works fine.I also implemented Websocket channels which work fine as well, however, i want to send a message to a specific websocket channel (of a user) from the background task about its progress when it is running.This does not work and i am a bit confused if i understand correctly how it is supposed to work.I can save websocket channel names or groups of specific users in the main app fine and send messages to individual users, however this does not work from the background task which is supposedly running in another thread.Is this by design, eg. not possible or should it work that i can send messages back and forth between different channels even if they are in different threads? I am using the redis backend.As per https://github.com/django/channels/issues/239 it looks like i have to persist channels name and then use them to send messages from an asynchronous background task to a websocket. So i tried to persist websocket connections of a user in the db and then access that field from the background task to send messages to that channel, but that also does not work.Now i am unsure if it is because i am doing something wrong, if this is by design, or what exactly i should be doing anyway.User Story:Logged in user has an active Websocket connection and clicks on a button to start importing data, which triggers a background task through django channels. The background task should send Progress updates back to the user via his/her websocket channelThanks in advance
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/ddb45a1e- .f3e4-4aeb-b5eb-e2d0ccef2356% 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/CAFwN1urNPHo8ptJEMF5Bdw2npgWUOFEnEJEC0RmHa%2BgFCMKPxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment