Coding a Simple WebSocket Server in Node.js that Scales!
Вставка
- Опубліковано 9 бер 2023
- A quick intro into coding a basic WebSocket server using the fast and efficient NPM package ws.
GitHub Repo: github.com/covalence-io/ws-si...
Express Template Repo: github.com/covalence-io/expre...
Don't forget to like this video and subscribe to our channel - we're publishing more videos and walkthroughs every week. Comment below and let us know what you'd like to see next!
Check us out at covalence.io
Join the Covalence community: covalence.io/membership
Shop Covalence merch: covalence.merchntly.com
We need more of the websocket lessons. Thank you, really apppreciate it. So much production-related use cases we are in demand of. Please make more videos! For example, how to send messages in controllers, how to separate websocket, how to authenticate etc. etc.
Really appreciate how you explained everything from scratch. Helped me build the basic intuition of websockets. Keep doing the good work. Cheers
That channel is so under rated
Everything is here. Not too much not too little and also the explanations for productive use are super. However, I admit that I always had to stop. The speed is ok nonetheless. Thank you very much for your effort. Without your video and GPT I would not be where I am now in 4 weeks!
Glad you're enjoying the content!
Hey Matt, good video, thank you for all your help. A suggestion for future videos, maybe zoom out a bit and make the window you're coding in a bit bigger; it would help me to see more of the code at once. Thank you.
Noted! Appreciate the feedback.
increase your sound in the video i will start watching your videos, you are creating quality content just keep it up, whenever I watch videos from this channel I have seen to grow their channel much faster after my continue watch. Quality content attracts me and youtube recommends that
Bro great video..however can you increase your audio volume in future videos please..tx
Thank you for the tutorial very simple and very informative. Can you please share the resources you used to know about ws other than ws-docs.
Apologies, the only resources I have are from looking at their code, working with the library myself, and various feedback from the experiences of colleagues working with the libraries
could you do a video on amqplib and rabbitMQ?
At 8:33, you talked about auth, can you make video about this part?
Thank you.
We have this video ua-cam.com/video/twNgfrE4ShE/v-deo.html you can check out!
why if(!!ws) instead of if(ws)
My react app is unable to connect, am getting response 404 status
when are you getting a 404? when the websocket is trying to connect or when the page loads or what? where do you see the 404 error?
Hello! I tried to write a simple (non-scalable) web server. But there are in satellite phone networks a connection can be destroyed unexpectedly - but a channel of data transmission in phone stay alive (an indicator on a phone show that data transmission in action) . When a server sending ping to a client each minute (for example) - you can set timeout and kill the connection when a response has`n been received. But a client think - the connection is alive... In my opinion - the solution is the next: we can send from a frontend (browser) pings periodically and responding by a server. Timeout mechanisms must be on both sides: s frontend side and a backend side. But a browser hasn't any event handlers for websocket`s 'ping'. It also can't sends pings to server (a browser only responding on websocket pings) . In fact, I can`t listen 'ping' on a browser side. It`s a disadvantage. Classical TCP Socket in Nodejs can sending keep-alive events from a client or from a server side
We have another video that should solve this problem here! ua-cam.com/video/cUGRlM3SZ1w/v-deo.html
@@covalence-io Thanks!
Can we host this on vercel ?
I'm not sure if Vercel has websocket support or not. I would look into whether or not Next.js will work with websockets and if so then Vercel probably has some way to support them as well
@@covalence-io Yes I found out that vercel doesn't have support for websockets, so I hosted my backend on Render but it is little slow. I can see the delay in responses.
how to deploy it on server
It is a server.
Why do you use --save for, that is completely useless.
--save adds the package as a dependency in your package.json, if you do --save-dev it'll add it as a dev dependency
@@covalence-io all packages are saved to your list of dependencies since npm version 5 ^ --save-dev however is sill necessary to save to your list of dev dependencies.
@@user-mq9dy2lj5u old habits die hard haha. I explicitly use --save, --save-dev, and --no-save every time i install for some reason but yes you are 100% correct in that the --save is the default behavior
Can't trust somebody who is constantly looking at his notes, lol!
Actually you can trust that somebody way more...