hello someone help me i am getting django 404 error ..how fix it ...please 
help me i am so frustrated


On Wednesday, 3 October 2018 04:23:30 UTC-7, Matt F wrote:
>
> Hello all,
>
> I have a question about the process of accepting/rejecting web socket 
> connections in Channels consumers (v2.1.3).  I have found that if I have 
> code like this:
>
> class MyConsumer(JsonWebsocketConsumer):
>     def connect(self):
>         if authenticated:
>             self.accept()
>         else:
>             self.close(4001)
>
>
> then when rejecting a connection the close code always comes through on 
> the client side as 1006 (abnormal closure) instead of 4001.  There is a 
> stack overflow post about the same issue that led me to an answer that 
> solves this: 
> https://stackoverflow.com/questions/50009440/django-channels-2-0-websocketbridge-js-403-when-self-codecode-1007
>
> And a code snippet that works correctly is as follows:
>
> class MyConsumer(JsonWebsocketConsumer):
>     def connect(self):
>         self.accept()
>         if not authenticated:
>             self.close(4001)
>
>
> The Channels documentation is ambiguous as to which of these is correct.  
> Now I think I know the answer as the first way breaks and the second way 
> works, but I wanted to check with someone more knowledgeable that this way 
> of doing things is by design and not just working by accident.  It feels a 
> bit wrong to accept a connection and then immediately close it, but I 
> understand if you have to do it this way, to get the custom close code 
> returned perhaps you have to have an open connection in the first place.  
> Can someone please confirm?
>
> Many thanks!
> Matt
>
>

-- 
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+unsubscr...@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/0cb3c59f-21c6-4e3c-b7f2-2242e59e4e58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to