Тёмный

DJANGO CHANNELS || Django Real-Time Application || Tutorial 2020 || WebSockets Async 

Technology for Noobs
Подписаться 6 тыс.
Просмотров 40 тыс.
50% 1

Опубликовано:

 

29 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 281   
@rohanabraham4461
@rohanabraham4461 3 года назад
can we just take a moment to appreciate the fact that this guys still responds to queries 8 months after upload
@zahirivan9155
@zahirivan9155 3 года назад
i guess Im randomly asking but does anybody know of a tool to log back into an instagram account? I was dumb forgot my password. I would love any help you can give me!
@technologyfornoobs
@technologyfornoobs 2 года назад
Thanks!
@technologyfornoobs
@technologyfornoobs 2 года назад
you can use password reset.
@lets_see_777
@lets_see_777 4 года назад
this is one of the best tutorials, fast and in structure explaining
@technologyfornoobs
@technologyfornoobs 4 года назад
Thanks!
@miloskaraklajic3413
@miloskaraklajic3413 4 года назад
I actually now understand the django channels. Thank you!
@technologyfornoobs
@technologyfornoobs 4 года назад
Thanks!
@rishabhnitc
@rishabhnitc 4 года назад
Thanks for making good content. For the people following along the notebook is referring to websocket-client package. Also the use ws = websocket.create_connection('ws://localhost:8000/ws/polData/') to connect from ipnyb. Also I would recommend author to use requirements.txt files to using pip freeze to make it easier for people to follow the course
@technologyfornoobs
@technologyfornoobs 4 года назад
Super!
@cyri4921
@cyri4921 2 года назад
This is truly the tutorial of all time
@technologyfornoobs
@technologyfornoobs Год назад
Thanks!
@johnhouse6870
@johnhouse6870 3 года назад
Apparently for python versions greater than 3.6 they recommend adding .as_asgi to the url routing. websocket_urlPattern=[ path('ws/polData/',consumer.DashConsumer.as_asgi()), ] using the adjustment to the url and the following in the client code I was able to establish a connection ws = websocket.WebSocket(sslopt={"check_hostname": False}) ws.connect("ws://localhost:8000/ws/polData/") Thanks John
@technologyfornoobs
@technologyfornoobs 3 года назад
yes now Django provide wsgi.py and asgi.py when we create project.
@saikirangutla9256
@saikirangutla9256 4 года назад
Worthy video for getting started with web sockets. Thanks bro
@technologyfornoobs
@technologyfornoobs 4 года назад
Glad you liked it
@vikashverma3401
@vikashverma3401 3 года назад
Don't underestimate the coding of small creators👍👍❤️❤️
@technologyfornoobs
@technologyfornoobs 3 года назад
Yo!
@amruthap6334
@amruthap6334 4 года назад
omg such an amazing content. loved it ❤❤
@technologyfornoobs
@technologyfornoobs 4 года назад
Thank you so much!!
@oryankibandi3556
@oryankibandi3556 3 года назад
Best tutorial i've watched
@technologyfornoobs
@technologyfornoobs 2 года назад
Thanks!
@jayamankrah4328
@jayamankrah4328 4 года назад
I have now got a good understanding how django channels work. Thank you for the perfect content. Please can you make a video about how to use it to fetch data from database. Much love🥰❤❤❤
@technologyfornoobs
@technologyfornoobs 4 года назад
Noted
@ulriknash5502
@ulriknash5502 2 года назад
@@technologyfornoobs That would add the icing on the cake!
@technoinfoworldwide2329
@technoinfoworldwide2329 4 года назад
awesome tutorial ...i request you to make tutorial on how many users click the link, their ip address,i mean tracking their activities in graph from in backend side of blog website?
@federicosironi135
@federicosironi135 4 года назад
use signals from django
@ronitjain6704
@ronitjain6704 3 года назад
just amazing !! beautifully explained !!
@technologyfornoobs
@technologyfornoobs 3 года назад
Glad it helped!
@TheNeonbuffalo
@TheNeonbuffalo 4 года назад
Dude totally underrated video. You did such a great job of explaining the theory and implementation of this thank you. I am definitely subscribing and will be eagerly waiting for new videos. Btw as a windows user I ran into a few issues. Below are the solutions that helped: Issue 1: When installing channels (pip install channels) I kept getting an error when it attempted to install Twisted Solution: Use Python 3.7 instead of 3.8, twisted is not supported on 3.8 Issue 2: aioredis.errors.ReplyError: ERR unknown command 'BZPOPMIN', this happens because redis is not supported on windows Solution: Install the Ubuntu 20 app in the windows store and activate the WSL. When you run the app update+upgrade your repos (sudo apt update; sudo apt upgrade -y) then install redis-server and redis-cli (sudo apt install redis-server -y; sudo apt install redis-cli -y) this should install redis version 5. type the command, redis-server to start redis then you shouldnt be good to run django and publish data. I hope this helps.
@technologyfornoobs
@technologyfornoobs 4 года назад
Great!
@ashkanoliaie6548
@ashkanoliaie6548 4 года назад
Hey man , I had this twisted problem before , for python 3.8 u need to download twisted urself for python 3.8 and then install it locally with pip in your project ,at least that's what I did , I'd like to know if u came up with a better solution. and for the redis you could use docker it's very easy u just start a redis server. good luck :) I hope this helps a little
@benlevy403
@benlevy403 4 года назад
@@ashkanoliaie6548 I've tried many solutions like using WSL 2, installing an older version of redis and using docker on my windows machine to use redis and have not been able to shake the BZPOPMIN error. I've gotten the redis server running in a bunch of different ways but am yet to successfully connect. Does anyone have an explicit basic step-by-step solution on how to run and connect to a redis server in windows? I'm sure I'm missing something simple, docker seems to be easy enough but I just keep getting this error. Thanks in advance
@pumpkinthestrange1
@pumpkinthestrange1 2 года назад
great video, nice way of showing on charts!
@technologyfornoobs
@technologyfornoobs 2 года назад
Glad you liked it!
@doditsuprianto4304
@doditsuprianto4304 3 года назад
man.... this is a very cool tutorial, good job.
@technologyfornoobs
@technologyfornoobs 3 года назад
Glad you liked it!
@doditsuprianto4304
@doditsuprianto4304 3 года назад
@@technologyfornoobs If I will implement the system in IoT, some architectures involve broker (redis) and worker (celery), why is that? Here you show, the django channel can solve this problem. Then what about the role of the MQTT broker (mosquitto)? can redis replace it? Maybe you can help explain it. Regards
@technologyfornoobs
@technologyfornoobs 3 года назад
@@doditsuprianto4304 I am not an expert in IoT infra kinds of stuff, yes Redis is still needed in our implementation as well for obvious reasons, and WebSockets is another protocol and MQTT is a diff protocol, where the data packet is even smaller than what we have done in WebSockets.
@mdmasud5888
@mdmasud5888 4 года назад
Very nice tutorial. thanks for sharing.
@technologyfornoobs
@technologyfornoobs 4 года назад
Thank you! Cheers!
@skysavani7095
@skysavani7095 3 года назад
Thanks for this amazing tutorial and example code
@technologyfornoobs
@technologyfornoobs 2 года назад
You are welcome!
@NphiniT
@NphiniT 4 года назад
If you're on Windows and you have problems installing channels with an error like: Microsoft Visual C++ 14 is required, Download Twisted from www.lfd.uci.edu/~gohlke/pythonlibs/#twisted. Choose the win32 one corresponding to your python version. For instance, I used Python 3.8; so I downloaded Twisted‑20.3.0‑cp38‑cp38‑win32.whl (Notice "cp38"). Once downloaded, navigate to the download folder in your command prompt and run 'pip install ' followed by the file u just downloaded. After this you can install channels or whatever. You're welcome!
@technologyfornoobs
@technologyfornoobs 4 года назад
Nice tip!
@vikashverma3401
@vikashverma3401 3 года назад
Pip install pipwin Pipwin install twisted This is super trick if any pkg getting error in installing..
@ajiteshpratapsingh3500
@ajiteshpratapsingh3500 4 года назад
Great Work. Worth watching if you want to learn and implement basic Web sockets in django
@technologyfornoobs
@technologyfornoobs 2 года назад
Thanks!
@harshkumar8382
@harshkumar8382 4 года назад
Great work sir..
@technologyfornoobs
@technologyfornoobs 4 года назад
Thanks a ton
@dnj86
@dnj86 2 года назад
Thanks for the tutorial. How would this solution works when scaling up (horizontal scaling - multiple instance of the server) ?.
@technologyfornoobs
@technologyfornoobs 2 года назад
I would not recommend this approach then.
@dnj86
@dnj86 2 года назад
@@technologyfornoobs Any recommendations for scaling?
@technologyfornoobs
@technologyfornoobs 2 года назад
@@dnj86 Scaling is a different beast, what I did was a PoC where people with few resources or a single resource are just trying to get something in action. to showcase, if a scalale solution needs to be built, another tech stack needs to be introduced. Not just python In my opinion.
@juancarloselorriaga6171
@juancarloselorriaga6171 4 года назад
Thanks! perfect tutorial
@technologyfornoobs
@technologyfornoobs 4 года назад
You're welcome!
@DD-be9gb
@DD-be9gb 3 года назад
Great video bro! Thanks
@technologyfornoobs
@technologyfornoobs 3 года назад
Glad you liked it!
@souhardswami3586
@souhardswami3586 4 года назад
Great explanation.🔥🔥🔥🔥🔥🔥🔥
@technologyfornoobs
@technologyfornoobs 4 года назад
Glad you liked it!
@dheeraj5023
@dheeraj5023 4 года назад
Cool, I understand, but I don't understand why use group in costumer please make more videos about this. Thanks God bless you 👍
@technologyfornoobs
@technologyfornoobs 4 года назад
Noted
@shubhamdixit9831
@shubhamdixit9831 4 года назад
Very nice tutorial. I am facing a problem of ws=websocket.WebSocket().It is throwing an error of -__init__() missing 3 required positional arguments: 'environ', 'socket', and 'rfile'
@technologyfornoobs
@technologyfornoobs 4 года назад
there are 2 libraries websocket-client==0.57.0, websockets==8.1, the one in notebook is client one.
@hackathon4904
@hackathon4904 3 года назад
I am facing the same problem.
@mashoodurrehman9840
@mashoodurrehman9840 4 года назад
Awesome video. Please make a series on django channels
@technologyfornoobs
@technologyfornoobs 4 года назад
Will surely do that.
@euskola
@euskola 2 года назад
Great tutorial! How can I send data from a server to a ML algorithm in Django that then process it and send the data to a real time graph? Any suggestion? Thanks!
@technologyfornoobs
@technologyfornoobs Год назад
I think you might know the answer after going through the video.
@harshitsantosh825
@harshitsantosh825 4 года назад
Great explanation. But how are you creating the messages which is shown in 28:42 ?
@technologyfornoobs
@technologyfornoobs 4 года назад
The error message? It's default from the server
@harshitsantosh825
@harshitsantosh825 4 года назад
@@technologyfornoobs - no, how are sending messages through websocket-client
@technologyfornoobs
@technologyfornoobs 4 года назад
websocket client is a library which provides api to communicate with websockets, more detailed info github.com/websocket-client/websocket-client
@harshitsantosh825
@harshitsantosh825 4 года назад
@@technologyfornoobs thanks
@KrishnaManohar8021
@KrishnaManohar8021 4 года назад
clear cut explanation! Awesome
@technologyfornoobs
@technologyfornoobs 4 года назад
Glad it was helpful!
@hcfercho
@hcfercho 4 года назад
Excelente video you have a new subscriber!
@technologyfornoobs
@technologyfornoobs 4 года назад
Awesome, thank you!
@anonymousleonard9948
@anonymousleonard9948 3 года назад
Thank You, I've been understanding really well, but at 38:52, after trying to connect the subscriber to the server I get: in main async def queue_factory() -> asyncio.Queue[str]: TypeError: 'type' object is not subscriptable , please help!
@technologyfornoobs
@technologyfornoobs 3 года назад
check the websocket library which you are using, the one in notebook is websocket-client
@anonymousleonard9948
@anonymousleonard9948 3 года назад
@@technologyfornoobs Now after installing websocket-client it says: No module named websocket.__main__; 'websocket' is a package and cannot be directly executed
@technologyfornoobs
@technologyfornoobs 3 года назад
see you are missing some points in video, you need both websocket-client and websockets
@Gonelastvirus
@Gonelastvirus Год назад
Actually i am making web app for my final year project. can you tell me how can i open socket for each edge device, like in my project there will be edge device for each individual client and graph should only be plot for client who logged in into the system.
@technologyfornoobs
@technologyfornoobs Год назад
I would recommend you to go through the concepts again, may be you already know the answer, and also the video is quite old now, many things have change and many other technologies are available to do such things.
@Gonelastvirus
@Gonelastvirus Год назад
@@technologyfornoobs i just want token authentication for user authentication.Each edge device have unique token so that data sending from user edge device must display on their own homepage. if you have discord then we can chat there.
@Gonelastvirus
@Gonelastvirus Год назад
oh i got it i have to open channel for individual user.
@fotinik.6664
@fotinik.6664 2 года назад
Great Video! Can you identify the versions of the libraries you use?
@technologyfornoobs
@technologyfornoobs 2 года назад
I will check,
@anandsriram5242
@anandsriram5242 3 года назад
Great tutorial. I have a use case of creating a real time dashboard by fetching continuous data points from a websocket API exposed by a third party app. How do I establish a ws connection with that API using channels?
@technologyfornoobs
@technologyfornoobs 3 года назад
you just need a javascript here, unless you want to save it somewhere. you consume that api in the ui and show the graph.
@anandsriram5242
@anandsriram5242 3 года назад
@@technologyfornoobs I want the real time data points to be stored in the database as well. The architecture I thought of is similar to what you have demonstrated here. Is there a way to run the process of Jupyter notebook in the Django app itself, as a continuous background task or something?
@davidjimenezm1876
@davidjimenezm1876 4 года назад
Thank you very much awesome tutorial very useful and complete. If I want to send 6 different values what can I do?
@technologyfornoobs
@technologyfornoobs 4 года назад
Yes you can, in my video I kept the channel value as constant, you can also pass channel value as dynamic and accordingly websocket will send data and our server will update based on the channel the data belongs.
@alitatl9780
@alitatl9780 3 года назад
Awesome :D Thank you !
@technologyfornoobs
@technologyfornoobs 3 года назад
Glad you like it!
@gyanaranjannayak3333
@gyanaranjannayak3333 3 года назад
Thanks, sir for this amazing tutorial. I have a requirement where instead of a dashboard, there will be a table. And data in that table should update automatically when new data is added in DB and that is without refreshing the page. Can we use Channel in that case?
@technologyfornoobs
@technologyfornoobs 2 года назад
Yes, correct, there is a another video where I am updating the table real time check for it.
@ktrades2898
@ktrades2898 4 года назад
Great content, thanks for simplifying it. Do you deal with websocket addresses when you port the django app to google cloud?
@technologyfornoobs
@technologyfornoobs 4 года назад
i guess it would as in normal deploy scenario, noting needs to be changes, just care for the allow domain option.
@ktrades2898
@ktrades2898 4 года назад
@@technologyfornoobs Thanks for the reply. I was able to upload it to cloud. The roadblock was that Google App Engine doesn't support websockets, so I ended up using Google Compute Engine. I have a follow up questions. If you have multiple windows on a page all streaming, how do you extend the code?
@technologyfornoobs
@technologyfornoobs 4 года назад
do you mean multiple graphs? or just browser windows?, if multiple graphs, just make an addition in the consumer.py where I have fixed the channel name make it dynamic by sending it as a url parameter and do the required changes in the respective codes.
@ktrades2898
@ktrades2898 4 года назад
@@technologyfornoobs Multiple Graphs
@ktrades2898
@ktrades2898 4 года назад
I looked into consumer.py as you mentioned and created two classes and routed each websocket to different class. It has worked! Thanks for the suggestion.
@BlacksoulRider
@BlacksoulRider 4 года назад
Awesome !!!!
@technologyfornoobs
@technologyfornoobs 4 года назад
Thanks!!
@orangrefi3521
@orangrefi3521 4 года назад
Thanks bro...!! Can you make a video regarding deploying this project on production server.
@technologyfornoobs
@technologyfornoobs 4 года назад
Yes, soon
@muddymkamba352
@muddymkamba352 5 месяцев назад
I want to deploy channels with apache any leads on how to configure apache2 to perfom this
@muddymkamba352
@muddymkamba352 5 месяцев назад
I have tried with daphne and redis in development server is working fine but in apache I am getting error
@storememory
@storememory 4 года назад
Hi , i need to do a time series analysis of stock data. Where as i have to show live data graph on frontend ? How can u perform using lstm algorithm to show data and prediction on ui in django?
@technologyfornoobs
@technologyfornoobs 4 года назад
that could be simple and could be complicated.what's your input structure for LSTM would define the complication in approach, as in real time you will get a single data point, and LSTM would need some window of data to process and predict. but just a clue in Consumer.py file >> receive part you would have the logic to predict.
@technologyfornoobs
@technologyfornoobs 4 года назад
Or you score it outside and send as another data point for dashboard, no need to include it in Django app.
@storememory
@storememory 4 года назад
@@technologyfornoobs thankyou for solution . I appreciate. Can you please tell me more about it. Like how can i exactly use realtime time series analysis of stock data. As of now i only have data in csv where as i could use the same in db and fetch in dashboard but when it comes to real time analysis, it really become hard.
@rishabhnitc
@rishabhnitc 4 года назад
@@storememory I think you need something more robust that this. There are dedicated tools for this problem e.g time series databases like KDB. if you want to have a crude implementation think about using a redis solution with a siding window and performing the calculation there using a pub sub mechanism. UI framework like django and channels are really not the place where business logic and critical processing should happen
@anonymousleonard9948
@anonymousleonard9948 3 года назад
@@storememory Hey Nishant, have you completed your analysis of stock data work? I just wanted a little help.
@mayurg2661
@mayurg2661 4 года назад
Great Content but how did you connect the websocket server from jupyter notebook since i keep getting this error: ws=websocket.WebSocket() TypeError: __init__() missing 3 required positional arguments: 'environ', 'socket', and 'rfile'
@technologyfornoobs
@technologyfornoobs 4 года назад
there are 2 libraries websocket-client==0.57.0, websockets==8.1, the one in notebook is client one.
@mayurg2661
@mayurg2661 4 года назад
@@technologyfornoobs Thanks for getting back to me and for your help. Really appreciate. Do you have an email address I can message you on?
@technologyfornoobs
@technologyfornoobs 4 года назад
@@mayurg2661 techfornoobs01@gmail.com
@mayurg2661
@mayurg2661 4 года назад
@@technologyfornoobs sent you an email
@adarshgupta9272
@adarshgupta9272 3 года назад
amazing tutorial
@technologyfornoobs
@technologyfornoobs 3 года назад
Thank you! Cheers!
@ajairahouse7058
@ajairahouse7058 4 года назад
I have little confusion about it that We can can send data from client(publisher) to server without redis,then why we have use redis server here? I run this code without redis but I see that it can perfectly send data to server. Hopefully you will reply and help me to know about it. Thanks
@technologyfornoobs
@technologyfornoobs 4 года назад
We have defined the redis server config in settings if you notice, redis helps on this communication. Django also provides a default server for websocket but it's not recommended to use. Just another point, server is using the redis not client
@bilalali9954
@bilalali9954 4 года назад
Great work brother It solved major portion of my problem and helped me to design my code flow. But i am confused about channel layer, and redis. Do we have to run redis on another server in production?? And can you please make a video or deployment?
@technologyfornoobs
@technologyfornoobs 4 года назад
not in another server at the same server, and defied it in the settings.
@bilalali9954
@bilalali9954 4 года назад
@@technologyfornoobs can i contact you on whatsapp or your email if you dont mind??
@technologyfornoobs
@technologyfornoobs 4 года назад
Ping me at Techfornoobs01@gmail.com
@bilalali9954
@bilalali9954 4 года назад
@@technologyfornoobs Hey hope you're doing good, do you know any free resoucre where i can deploy my django-channels applicaiton free/without credit card
@technologyfornoobs
@technologyfornoobs 4 года назад
I guess no, credit card is mandatory step in any service now a days.
@ThiagoAraujo-hh6xu
@ThiagoAraujo-hh6xu 4 года назад
I am getting an error on the ws=websocket.WebSocket. Follow the error msg: "TypeError: __init__() missing 3 required positional arguments: 'environ', 'socket', and 'rfile'". Any idea what is wrong?
@technologyfornoobs
@technologyfornoobs 4 года назад
please check the python and websocket version you are using, you can match it with requirement.txt file in the git.
@ThiagoAraujo-hh6xu
@ThiagoAraujo-hh6xu 4 года назад
@@technologyfornoobs I found the issue. I installed websocket instead of websocket-client. Thanks for answering. Then later in the video, I also had to install websocket. It would be easier if I had follow your requirements.txt. I also had problems with the newer version of channels_redis(as I am on windows). Then I had to specify the correct channels_redis version to install. Now it is working.
@himanshsworld
@himanshsworld 3 года назад
Can we authentic the request that which user is sending the request
@technologyfornoobs
@technologyfornoobs 3 года назад
yes
@sumantam9401
@sumantam9401 4 года назад
looking a django project which will store the console output to a txt file and same thing need to be displayed on the UI page as well
@technologyfornoobs
@technologyfornoobs 4 года назад
Could be a good exercise, don't look for it, you may already know now how to implement it.
@pazbazak5334
@pazbazak5334 4 года назад
great video!
@technologyfornoobs
@technologyfornoobs 4 года назад
Thanks for the visit
@MadhanMohanReddyB
@MadhanMohanReddyB 3 года назад
Setting up Django environment is a real challenge, several package dependencies. Though there is online support and forums to help but it is gets outdated within dates with new updated packages.
@technologyfornoobs
@technologyfornoobs 3 года назад
that's why it is important to work in a separate environment.
@MadhanMohanReddyB
@MadhanMohanReddyB 3 года назад
@@technologyfornoobs Can you please provide answers to previous questions below?
@mohammedbayomy6154
@mohammedbayomy6154 4 года назад
many thanks to you sir
@technologyfornoobs
@technologyfornoobs 4 года назад
Thanks!
@kuldeepmali6947
@kuldeepmali6947 4 года назад
Thank you Brother ❤❤❤❤❤❤❤❤❤❤
@technologyfornoobs
@technologyfornoobs 4 года назад
Thank you too
@Mukeshkumar-yl1qq
@Mukeshkumar-yl1qq 2 года назад
Thank you so much
@technologyfornoobs
@technologyfornoobs 2 года назад
You're most welcome
@bijitakc3126
@bijitakc3126 4 года назад
Can we integrate a tensorflow python chatbot in a django website using this?
@technologyfornoobs
@technologyfornoobs 4 года назад
that could be a good project, let me check.
@bijitakc3126
@bijitakc3126 4 года назад
@@technologyfornoobs sure.thank you for the help!
@irfansayyed6142
@irfansayyed6142 4 года назад
🔥 🔥 🔥 Awesome Tutorial Can we stream serial data or output through websockets ?
@technologyfornoobs
@technologyfornoobs 4 года назад
I think it's possible, but need to be tried first, but I guess its possible sending a bit at a time.
@etemkeskin5025
@etemkeskin5025 3 года назад
consumer.DashConsumer.as_asgi() When I add .as_asgi(), my code worked at routing.py. Why? Thanks for your sharing.
@etemkeskin5025
@etemkeskin5025 3 года назад
In routing.py, "as_asgi()" is required for versions over python 3.6.
@technologyfornoobs
@technologyfornoobs 2 года назад
Yo!
@msh6783
@msh6783 2 года назад
thank you🌹
@technologyfornoobs
@technologyfornoobs Год назад
You're welcome 😊
@SURJEETSINGH-ms9iu
@SURJEETSINGH-ms9iu 4 года назад
niceeyyy
@technologyfornoobs
@technologyfornoobs 4 года назад
Thanks
@vishalsuryawanshi8408
@vishalsuryawanshi8408 3 года назад
Why we need consumer if we can directly pass data from websocket into js
@technologyfornoobs
@technologyfornoobs 3 года назад
we need consumer for creating the webserver which can publish the data real-time to other consumers if you already have a WebSocket somewhere else you do not need Django component
@rishwanriju5791
@rishwanriju5791 3 года назад
such an amazing content, how can I connect this with angular service worker
@technologyfornoobs
@technologyfornoobs 3 года назад
instead of using the django templates for UI, we need to just use it as a API.
@mashoodurrehman9840
@mashoodurrehman9840 4 года назад
Please tell how to use channels in production. I'm having an error
@technologyfornoobs
@technologyfornoobs 4 года назад
I need to check about this, will update you, have you checked if Gunicorn supports ASGI?
@TrungNguyen-ty9fc
@TrungNguyen-ty9fc 4 года назад
Great tutorial! When I tried to do Websockers connect, I got this error: ... WebSocket HANDSHAKING /ws/polData/ [127.0.0.1:64222] WebSocket CONNECT /ws/polData/ [127.0.0.1:64222] Exception inside application: ERR unknown command 'BZPOPMIN' ... aioredis.errors.ReplyError: ERR unknown command 'BZPOPMIN' WebSocket DISCONNECT /ws/polData/ [127.0.0.1:64222] Any idea to address the error?
@technologyfornoobs
@technologyfornoobs 4 года назад
Can you check your redis version, also try the default django channel server instead of redis, that might solve the problem for now.
@TrungNguyen-ty9fc
@TrungNguyen-ty9fc 4 года назад
@@technologyfornoobs For solution, I installed Memurai as advised in stackoverflow.com/questions/62786988/redis-err-unknown-command-bzpopmin
@KrishnaManohar8021
@KrishnaManohar8021 4 года назад
can u make tutorial Django Rest Framework. OAuth, JWT, Sessions, cookies, etc. Security related concepts in Django.
@technologyfornoobs
@technologyfornoobs 4 года назад
All ready in the pipeline, will update soon.
@KrishnaManohar8021
@KrishnaManohar8021 4 года назад
@@technologyfornoobs thx.
@jameskulu
@jameskulu 4 года назад
where can i add an url if I am calling through an api?
@technologyfornoobs
@technologyfornoobs 4 года назад
Any where in apps url or in project urls or in ASGi urls
@sambitsahoo8071
@sambitsahoo8071 4 года назад
----> 1 ws=websocket.WebSocket() TypeError: __init__() missing 3 required positional arguments: 'environ', 'socket', and 'rfile' got this error and i didnt find the requirements.txt in the git
@sambitsahoo8071
@sambitsahoo8071 4 года назад
i m using django 3..there is already asgi.py..TypeError: object.__init__() takes exactly one argument (the instance to initialize) WebSocket DISCONNECT /ws/polData/ [127.0.0.1:57510]
@technologyfornoobs
@technologyfornoobs 4 года назад
Yes, you are using latest Django which gets you asgi.py file created. And I somehow do not have req.txt file missing in mostly all repositories, not sure why, But for now the error you have is not in django, but in Notebook I am assuming, and the solution for this is you need to install "websocket-client" not the "websocket" only. Try this
@hackathon4904
@hackathon4904 3 года назад
@@sambitsahoo8071 I am getting the same error!
@hackathon4904
@hackathon4904 3 года назад
@@technologyfornoobs The error is on the CLI. Not in the notebook.
@lakshaynz
@lakshaynz 4 года назад
Thank you !
@technologyfornoobs
@technologyfornoobs 4 года назад
yo!
@kamleshsawant4280
@kamleshsawant4280 4 года назад
Nice tutorial..!! Can you please explain how we can integrate celery with this project. As I am new to django I dont know how to do it. Specifically , what if I want to request some api for data which is sending to receive in websocket instead of running stand alone script in notebook??? it will be great for me if you suggest. Thank you.
@technologyfornoobs
@technologyfornoobs 4 года назад
I hope you have gone through this link for celery with django: docs.celeryproject.org/en/stable/django/first-steps-with-django.html You are asking, to call an rest API and then send the response to the websocket and proceed on >>> it is possible, but what would be your logic to call the rest, as websocket works on a concept of event, if event happens then all things initiated, So even in my application in the notebook I created a client which was subscribed to my websocket service and event happened and all process started. In your case you also have to write some client whether it is calling a rest or any data event by any device, but at the end it must be subscribed and push the data to your websocket service.
@kamleshsawant4280
@kamleshsawant4280 4 года назад
@@technologyfornoobs Thank you for quick reply.. I have read celery doc and implemented it. Problem I am facing is how can I push data from my task function within same project. Means as in your notebook app we first define websocket and send data with "ws.send(URL)" method. Should I use this way to push data in same project or is there any other method to do that. Sorry for my lack of knowledge. But I want to learn.
@prashantpansuriya84
@prashantpansuriya84 4 года назад
Thank You sir
@technologyfornoobs
@technologyfornoobs 4 года назад
Most welcome
@MadhanMohanReddyB
@MadhanMohanReddyB 3 года назад
I am seeing this problem, can you help resolve it. AttributeError: module 'websocket' has no attribute 'create_connection'
@technologyfornoobs
@technologyfornoobs 3 года назад
you need to install "websocket client", "websocket" is a separate module.
@MadhanMohanReddyB
@MadhanMohanReddyB 3 года назад
@@technologyfornoobs I am seeing another error now. File "test.py", line 8, in ws = websocket.create_connection('ws://localhost:8080/ws/polData/') File "/home/adtran/.local/lib/python3.8/site-packages/websocket/_core.py", line 592, in create_connection websock.connect(url, **options) File "/home/adtran/.local/lib/python3.8/site-packages/websocket/_core.py", line 248, in connect self.sock, addrs = connect(url, self.sock_opt, proxy_info(**options), File "/home/adtran/.local/lib/python3.8/site-packages/websocket/_http.py", line 120, in connect sock = _open_socket(addrinfo_list, options.sockopt, options.timeout) File "/home/adtran/.local/lib/python3.8/site-packages/websocket/_http.py", line 200, in _open_socket raise err File "/home/adtran/.local/lib/python3.8/site-packages/websocket/_http.py", line 175, in _open_socket sock.connect(address) ConnectionRefusedError: [Errno 111] Connection refused
@MadhanMohanReddyB
@MadhanMohanReddyB 3 года назад
@@technologyfornoobs Using IP of the server in connect request gives a different error. websocket.create_connection('ws://x.4.95.208:8080/ws/polData/') Traceback (most recent call last): File "", line 1, in File "/home/adtran/.local/lib/python3.8/site-packages/websocket/_core.py", line 592, in create_connection websock.connect(url, **options) File "/home/adtran/.local/lib/python3.8/site-packages/websocket/_core.py", line 252, in connect self.handshake_response = handshake(self.sock, *addrs, **options) File "/home/adtran/.local/lib/python3.8/site-packages/websocket/_handshake.py", line 79, in handshake status, resp = _get_resp_headers(sock) File "/home/adtran/.local/lib/python3.8/site-packages/websocket/_handshake.py", line 164, in _get_resp_headers raise WebSocketBadStatusException("Handshake status %d %s", status, status_message, resp_headers) websocket._exceptions.WebSocketBadStatusException: Handshake status 500 Internal server error ########################### Error on Django Server: Exception inside application: No application configured for scope type 'websocket' Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/channels/routing.py", line 73, in __call__ raise ValueError( ValueError: No application configured for scope type 'websocket' WebSocket DISCONNECT /ws/polData/ [x.4.95.208:43598]
@MadhanMohanReddyB
@MadhanMohanReddyB 3 года назад
@@technologyfornoobs Can you please help provide answers for below questions?
@technologyfornoobs
@technologyfornoobs 3 года назад
Hello, you need to have both websocket and websocket client in your env, websocket is used in django side, websocket-client is used in notebook to communicate as a 3rd party tool or device.
@johnhouse6870
@johnhouse6870 3 года назад
Thank you for the video. I am trying to develop a django dashboard for sensor data so it is really in line with what I am trying to do. I am getting an error with the Jupyter code. I have installed websocket-client and uninstalled websocket and websockets. The first error I get is ws=websocket.WebSocketApp() TypeError: __init__() missing 1 required positional argument: 'url' If I put the url in ws=websocket.WebSocketApp('ws://localhost:8000/ws/polData/') The following error comes up. ws.connect('ws://localhost:8000/ws/polData/') AttributeError: 'WebSocketApp' object has no attribute 'connect' No Handshake occurs Thoughts appreciated.
@technologyfornoobs
@technologyfornoobs 3 года назад
You dont need to uninstall the websocket and websockets. as they are needed for Django App
@johnhouse6870
@johnhouse6870 3 года назад
@@technologyfornoobs Thank you - it is working now.
@kiransalve403
@kiransalve403 3 года назад
please make projects on Shipping management system in django
@technologyfornoobs
@technologyfornoobs 3 года назад
Will Keep it in mind.
@revanthkumar3406
@revanthkumar3406 4 года назад
please do complete tutorail on django rest framework
@technologyfornoobs
@technologyfornoobs 4 года назад
That is in progress!
@KrishnaManohar8021
@KrishnaManohar8021 4 года назад
+1
@hackathon4904
@hackathon4904 3 года назад
How do I get an analog sensor's data values?
@technologyfornoobs
@technologyfornoobs 3 года назад
Where is your sensor connected, depends on that, if raspberry pi then all sensor has some module which can help you on sending the data.
@hackathon4904
@hackathon4904 3 года назад
@@technologyfornoobs My sensor is connected to ESP8266 NodeMCU.
@technologyfornoobs
@technologyfornoobs 3 года назад
is there a way to make rest calls in this device?
@KrishnaManohar8021
@KrishnaManohar8021 4 года назад
My Suggestion: can you make telegram group for communicate better way.
@technologyfornoobs
@technologyfornoobs 4 года назад
you can connect at techfornoobs01@gmail.com, will check about telegram.
@namangupta2587
@namangupta2587 4 года назад
bro could you make a recommendation system using tensorflow and integrate the model in a e - commerace type web application of django. please bro... by the ways loved your videos
@technologyfornoobs
@technologyfornoobs 4 года назад
yes, its possible, its just the stack would be different and video would be long. :)
@namangupta2587
@namangupta2587 4 года назад
@@technologyfornoobs i request you please make a video on that😍😍
@technologyfornoobs
@technologyfornoobs 4 года назад
But recommendation using Neural network is itself a challenging task, mainly those are done using other algotithms
@namangupta2587
@namangupta2587 4 года назад
@@technologyfornoobs bro.... Plz make a video of django integration with react js and any simple project on it....
@RenalTutor
@RenalTutor 3 года назад
what are you doing in 29:23 ?
@technologyfornoobs
@technologyfornoobs 3 года назад
trying to communicate to the app using a simulated env, i.e notebook in this case.
@vikashverma3401
@vikashverma3401 3 года назад
Pip install pipwin Pipwin install twisted This is super trick if any pkg getting error in installing..
@technologyfornoobs
@technologyfornoobs 3 года назад
Great!
@yashmathur1389
@yashmathur1389 4 года назад
How Have you created this web socket client to send data to the server
@technologyfornoobs
@technologyfornoobs 4 года назад
using a package websockets in python
@yashmathur1389
@yashmathur1389 4 года назад
@@technologyfornoobs at 28:52 from where are you sending data to the routing port. Cause i am receiving error, "no connection made, because target machine actively refused it." which website are you using to generate client side data? How can i generate the same on my system itself? please elaborate
@technologyfornoobs
@technologyfornoobs 4 года назад
@@yashmathur1389 have you started the django server and redis server?
@yashmathur1389
@yashmathur1389 4 года назад
@@technologyfornoobsyou are using redis server or the default server django provides
@yashmathur1389
@yashmathur1389 4 года назад
i am not using redis server and default server is on
@umeshsaruk6482
@umeshsaruk6482 4 года назад
Awesome video mate. Do you have a twitter handle to follow?
@technologyfornoobs
@technologyfornoobs 4 года назад
No, sorry
@vishruth8708
@vishruth8708 4 года назад
How to create 2nd page after login and to display Images ..
@vishruth8708
@vishruth8708 4 года назад
To display images in such a way that..it should display person who added name and no of times others downloaded
@technologyfornoobs
@technologyfornoobs 4 года назад
You have to maintain a database to show the records,and with the action in button click add a value to the number of download counts
@vishruth8708
@vishruth8708 4 года назад
@@technologyfornoobs Please show that in your channel ..
@aayushpatil7514
@aayushpatil7514 4 года назад
Can you make chatting appliaction on web with this?please
@technologyfornoobs
@technologyfornoobs 4 года назад
Thats the default app which people create using websockets and channels. Its in the Channels documentation as well.
@aayushpatil7514
@aayushpatil7514 4 года назад
@@technologyfornoobs Ya But I think it is real-time and I want to store the message so that whenever anyone loads the page all the message will be there forever
@technologyfornoobs
@technologyfornoobs 4 года назад
the moment you get the message in your websocket server, you can add the logic to add it in database.
@thegeevavsubhacollectives
@thegeevavsubhacollectives 3 года назад
how to do this in MQTT?
@technologyfornoobs
@technologyfornoobs 3 года назад
Some work are already done , I guess you should be able to find it.
@spkharode
@spkharode 4 года назад
Hi, I got this issue with websocket connection as it is getting closed due to handshake error , The error Message are as below: WebSocket HANDSHAKING /ws/polData/ [127.0.0.1:59304] Exception inside application: object.__init__() takes exactly one argument (the instance to initialize) Traceback (most recent call last): File "/usr/lib/python3.7/site-packages/channels/routing.py", line 71, in __call__ return await application(scope, receive, send) File "/usr/lib/python3.7/site-packages/channels/sessions.py", line 47, in __call__ return await self.inner(dict(scope, cookies=cookies), receive, send) File "/usr/lib/python3.7/site-packages/channels/sessions.py", line 172, in __call__ return await self.inner(self.scope, receive, self.send) File "/usr/lib/python3.7/site-packages/channels/auth.py", line 181, in __call__ return await super().__call__(scope, receive, send) File "/usr/lib/python3.7/site-packages/channels/middleware.py", line 26, in __call__ return await self.inner(scope, receive, send) File "/usr/lib/python3.7/site-packages/channels/routing.py", line 160, in __call__ send, File "/usr/local/lib/python3.7/dist-packages/asgiref/compatibility.py", line 33, in new_application instance = application(scope) File "/usr/lib/python3.7/site-packages/channels/generic/websocket.py", line 159, in __init__ super().__init__(*args, **kwargs) TypeError: object.__init__() takes exactly one argument (the instance to initialize) WebSocket DISCONNECT /ws/polData/ [127.0.0.1:59304]\
@technologyfornoobs
@technologyfornoobs 4 года назад
I think you have wrong version of redis installed
@woutvandroogenbroeck8047
@woutvandroogenbroeck8047 3 года назад
@@technologyfornoobs also got this exact same issue, have the newest version of redis
@technologyfornoobs
@technologyfornoobs 3 года назад
@@woutvandroogenbroeck8047 github.com/sharmasw/realTime-Tables-with-Django-Channels Use redis from this repo
@Motivational_hub_98
@Motivational_hub_98 3 года назад
When i tried,it showed me connection lost,why it was!!!
@technologyfornoobs
@technologyfornoobs 3 года назад
Please try to debug or at least give some error details
@django3861
@django3861 3 года назад
group add none type error beacause of channel layer github.com/django/channels/issues/1036 it doesn't matter that you follow video
@pradeepbhat8778
@pradeepbhat8778 3 года назад
Hey, really amazing content, I was searching for this only. I am working on my own data analysis backend and I have very similar requirement, but the source of data is different and I am stuck on that. I would like to get your insight on same. How can I contact you ? Hope you will reply
@technologyfornoobs
@technologyfornoobs 2 года назад
Connect via email @ techfornoobs01@gmail.com
@jackiechann3689
@jackiechann3689 4 года назад
Django 3.1??
@technologyfornoobs
@technologyfornoobs 4 года назад
2.2.3 but would work on 3 as well
@rishabhnitc
@rishabhnitc 4 года назад
works with 3.1, I tried this with 3.1 and definitely works, see my other comment for very minor change you might have to make. Another minor change might be required to use the same with Daphne where you need to get the 'default' application and setup django instead of just the asgi application
@dheeraj5023
@dheeraj5023 3 года назад
Jupyter code not working as error
@technologyfornoobs
@technologyfornoobs 3 года назад
Not sure what issue you have, but may be if issue is at websocket line, then install websocket client
@dheeraj5023
@dheeraj5023 3 года назад
@@technologyfornoobs I have sent email error
@revanthkumar3406
@revanthkumar3406 4 года назад
do chat bot application using django without any frontend framework
@technologyfornoobs
@technologyfornoobs 4 года назад
You mean using console?
@revanthkumar3406
@revanthkumar3406 4 года назад
@@technologyfornoobs using js but not js framework(react,angular)
@technologyfornoobs
@technologyfornoobs 4 года назад
The default example in Django Channels has the same chat project, its plain javascript
@pawankushwah4992
@pawankushwah4992 4 года назад
Why u not mention scope ?
@technologyfornoobs
@technologyfornoobs 4 года назад
Consumers receive the connection’s scope when they are initialized, which contains a lot of the information you’d find on the request object in a Django view. It’s available as self.scope inside the consumer’s methods.
@pawankushwah4992
@pawankushwah4992 4 года назад
@@technologyfornoobs how to check , second user disconnected or not. I think in websocket _ disconnect function we have to use , self.channels.group_send( Group_name, { Type:'leave.room', message:'leve room'} ) method , am right or not .
@technologyfornoobs
@technologyfornoobs 4 года назад
yes some thing similar, by this logic you can also add how many user are in the chat room or if any user left the room kind of functionality, as the connection get closed by the user it does reach to disconnect functionality and as I haven't written anything so it does not do any thing.
@mostnotoriouspinpin7581
@mostnotoriouspinpin7581 2 года назад
can you please make a group chat like whatsap
@technologyfornoobs
@technologyfornoobs 2 года назад
I can but don't you think it will be over killing and all people will just ping and so all those notorious things will happen like sharing irrelevant contents
@mostnotoriouspinpin7581
@mostnotoriouspinpin7581 2 года назад
@@technologyfornoobs no bro i meant making a chatroom like app where users can create a room and others can join you can also give them the option to make public or private rooms that's what i have to for school but i already know about websockets and channels i just don't know how to create a database for the rooms and allow real time messaging in it
@technologyfornoobs
@technologyfornoobs 2 года назад
@@mostnotoriouspinpin7581 the project you are talking about is the example given in django real time websocket documentation
@mostnotoriouspinpin7581
@mostnotoriouspinpin7581 2 года назад
@@technologyfornoobs ok thanks man I'll take a look btw i sub
@Vilasppatil
@Vilasppatil 3 года назад
Hi It's a Nice Video. Is it require to have python code on third party sensors. or please let me know how to featch data from sensors to phyton programe . Appreciate if you help me and share your email Id.
@technologyfornoobs
@technologyfornoobs 3 года назад
Not required in 3rd party sensor, you just need a measure to subscribe to the websocket to send data. might be using curl, c any thing
@Vilasppatil
@Vilasppatil 3 года назад
@@technologyfornoobs Thank you Do you have any such video or referance document, Please
@technologyfornoobs
@technologyfornoobs 3 года назад
@@Vilasppatil No videos as of now. Just search for the same stack which you are looking for apart from python
@Vilasppatil
@Vilasppatil 3 года назад
@@technologyfornoobs Ok Thanks for reply. please let me know, if you can provide paid online coaching. My Email ID : vilasppatil@gmail.com
@technologyfornoobs
@technologyfornoobs 3 года назад
You can reach me at techfornoobs01@gmail.com
@scythe_op
@scythe_op 2 года назад
Amazing video. I needed some help with something. How can I contact you? Can I ask here?
@technologyfornoobs
@technologyfornoobs Год назад
How can I help you?
Далее
Django Channels & WebSockets Oversimplified
16:35
Просмотров 139 тыс.
How to use WebSockets with React and Node
1:11:51
Просмотров 32 тыс.