DJANGO CHANNELS 2教程(V2)-實時-WebSockets-非同步



DJANGO CHANNELS教程(V2)-實時-WebSockets-非同步

1-歡迎(0:00:00)
2-要求(0:49:22)
3-安裝和集成通道(0:01:38)
4-您的第一個消費者(0:05:47)
5-路由您的WebSocket(0:10:41)
6-帶JavaScript的WebSocket(0:17:22)
7-接受WebSocket連接(0:23:25)
8-用戶和資料庫對象(0:27:08)
9-使用JavaScript發送數據(0:31:09)
10-回聲消息(0:39:00)
11-顯示消息(0:43:23)
12-整合Redis(0:50:25)
13-創建聊天室(0:54:24)
14-重新連接並保存(1:04:30)

ChatXChannels課程:https://kirr.co/vmd13r
代碼:https://github.com/codingforentrepreneurs/Rapid-ChatXChannels
訂閱:http://joincfe.com/youtube
專業人士:http://kirr.co/ni5fia。

50 comments
  1. ASGI alone is not good enough, especially for production level. it is better to use both. WSGI for http and asgi for websocket

  2. when i tried to import chat in routing.py pycharm does not recognise it, so i had to go one level up "from ..chat.consumers import "ChatConsumers" it correctly imported but at running runserver it says 'beyond top level package error in relative import " can somebody please help me :'(

  3. After many tutorials I have been reading on the internet about channels, this was the best by far. It's very clear and everything used/showed in the video is explained. Thank you! I can now correctly understand and control WebSocket with Channels! If I can just add a small remark, it would explain why you choose to use "AsyncConsumer" more than "AsyncWebsocketConsumer" or "AsyncJsonWebsocketConsumer" and the difference between each of them (useful to understand with one is "low level" for the others one, etc…)

  4. If you are trying to put this into production by using uvicorn and are getting the following error "Django can only handle ASGI/HTTP connections, not websocket." its because you should call get_default_application() from the channels.routing instead of get_asgi_application() from the django core. (ps: You have to call django.setup() before)

  5. Did I miss something? Where did you created this input in template? When did you create those models in models.py?

    I also check your github and it is not working like here on video.
    Am i miss something?

  6. Can you please help me? whenever I am doing socket.send, I am getting this error. I am unable to track the reason of the error and I have been at it for hours. I am at 34:25 and unable to go into websocket_recieve method

    Exception inside application: No handler for message type websocket.receive
    File "E:pythonprojectsRapid-ChatXChannelssrcvenvlibsite-packageschannelssessions.py", li
    ne 183, in _call_
    return await self.inner(receive, self.send)

    File "E:pythonprojectsRapid-ChatXChannelssrcvenvlibsite-packageschannelsmiddleware.py",
    line 41, in coroutine_call
    await inner_instance(receive, send)
    File "E:pythonprojectsRapid-ChatXChannelssrcvenvlibsite-packageschannelsconsumer.py", li
    ne 59, in _call_
    [receive, self.channel_receive], self.dispatch
    File "E:pythonprojectsRapid-ChatXChannelssrcvenvlibsite-packageschannelsutils.py", line
    52, in await_many_dispatch
    await dispatch(result)
    File "E:pythonprojectsRapid-ChatXChannelssrcvenvlibsite-packageschannelsconsumer.py", li
    ne 75, in dispatch
    raise ValueError("No handler for message type %s" % message["type"])
    No handler for message type websocket.receive

  7. God, I started with you the path to django and python, from the blog on django, I took that code style from you) and so far it is everywhere with me, I remember asking you to do a tutorial on channels for a long time ago, unfortunately I saw it just now) it was over errors that did not occur to you, the same with the output to the browser console, but as before thanks to you, I sat and dig it and found the answers) one of them is now on the stack. https://stackoverflow.com/questions/57443549/no-handler-for-message-type-websocket-group-send-how-to-fix/57462779#57462779

    Thank you, love you)

  8. Please i would love to see the tutorial of how you created the chat form. Please share the link so as i can follow along with great tutorial

  9. any ideas why i get a 200?

    [Log] Location {href: "https://plaagsex.nl/", protocol: "https:", host: "plaagsex.nl", hostname: "plaagsex.nl", port: "", …} (plaagsex.nl, line 3)
    [Error] WebSocket connection to 'wss://plaagsex.nl/' failed: Unexpected response code: 200
    [Log] error – Event {isTrusted: true, type: "error", target: WebSocket, …} (plaagsex.nl, line 24)
    Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}Eventbubbles: falsecancelBubble: falsecancelable: falsecomposed: falsecurrentTarget: nulldefaultPrevented: falseeventPhase: 0isTrusted: truereturnValue: truesrcElement: WebSocket {URL: "wss://plaagsex.nl/", url: "wss://plaagsex.nl/", readyState: 3, bufferedAmount: 0, onopen: function, …}WebSockettarget: WebSocket {URL: "wss://plaagsex.nl/", url: "wss://plaagsex.nl/", readyState: 3, bufferedAmount: 0, onopen: function, …}WebSockettimeStamp: 76type: "error"Event PrototypeAT_TARGET: 2BUBBLING_PHASE: 3CAPTURING_PHASE: 1NONE: 0bubblescancelBubblecancelablecomposedcomposedPath()constructor: function()currentTargetdefaultPreventedeventPhaseinitEvent(type, [bubbles], [cancelable])preventDefault()returnValuesrcElementstopImmediatePropagation()stopPropagation()targettimeStamptypeObject Prototype
    [Log] close – CloseEvent {isTrusted: true, wasClean: false, code: 1006, …} (plaagsex.nl, line 28)
    CloseEvent {isTrusted: true, wasClean: false, code: 1006, reason: "", type: "close", …}CloseEvent

  10. I have a basic query, The get_or_new method in the ThreadManager returns none if the username in the url and the logged in user are the same which will display the page not ound error message. Then how are you on the page 127.0.0.1/messages/cfe? I would understand if this has been abstracted so that people can join your course 🙂

  11. Great Video Justin! Been with you since 2015 and it's been awesome as ever!.
    Keep up the awesome work!
    Quick question; how would you take this further to send notifications to said users about the availability of new messages?

  12. Hi All, I don't see any setting of channel layer here, does the new channels library manage this under the hood? or the channel layer is optional? Can some one explain please

  13. I have a big problem, and I don't know what it is… basically I'm trying to run some pipeline, that I have to run scripts in R and Perl, and give some feedback link "this script have Start", "This script is complete", "Now startting script in R", and this pipeline is SYNC, and the feedback isn't comming one by one, it's more like a massive block at one.

    I was clear (I hope so…)?

  14. Maybe instead of using virtualenv etc, rather just use the python:3.6 Docker?

    Awesome bud btw. been using Django for years and decided to try out channels and this video made it super easy

  15. you make it seem like its so simple but you're skipping over a lot of details and youre not showing how channels works but how to make that project. Please show how channels and what it does and tries to do at every step. this video does not help as much because through this i dont understand what channels is actually doing and i dont know the flow of channels

Comments are closed.