Channels chat consumer behaves differently in prodcution vs development

11 views
Skip to first unread message

Adam Simon

unread,
Oct 6, 2019, 7:06:53 PM10/6/19
to Django users

I am using channels 2.x (along with nginx, daphne, redis and gunicorn)


In the local console I can see the user data I added in the chat consumer but not in my production environment


(in production everything else works, but the user is undefined. Note: the user is logged in.


Does anyone have any idea why that might be?


I followed the doc tutorial and the only thing i added was the line commented below


class ChatConsumer(WebsocketConsumer):


def chat_message(self, event):
    message = event['message'] # Send message to WebSocket
    self.send(text_data=json.dumps({
        'user': self.scope["user"].first_name, # <<< this is the line I added
        'message': message
    }))

Thanks,

Adam
Reply all
Reply to author
Forward
0 new messages