WebSockets with NodeJS (Express) and WebSocket API
How to set up a WebSockets Client and Server and Connect them!
-------------------------------------
Code: github.com/Vuka951/tutorial-c...
WebSocket API:
* developer.mozilla.org/en-US/d...
* developer.mozilla.org/en-US/d...
WS (WebSocket): www.npmjs.com/package/ws
--------------------------------------
Thanks for watching, if the video was helpful to you a like and/or a star to the github repo would be appreciated ❤️
Пікірлер: 57
Spent the whole day today to follow a 2 hours turorial on a web-socket-application and it didn't work, and I could't find the bug. And it felt like I didn't even understand what exactly I was coding on each line. This helped me capture it better. Thank you.
This is SO GREAT man. Exactly the amount of data necessary and the amount of pointing where to find out more. Great flow, very dense in information. Thank you.
I was struggling to get some concise guideline on this as an entry level coder and you made my day.
I've have been looking for an explanation on how to use websockets for 5 hours. I've been losing my mind about the amount of unclear explanations there were. You just saved my day and also my sanity. Thank you
After 4 days of torture I finally find your video. Simple and easy. You are the best, man.
@vuka951
4 жыл бұрын
Glad it was helpful!
bro, finally someone who explained this websocket communication right for beginnerrs. Thx a lot! u saved my project
Thanks man, this simple explanation really helped with cramping websockets into my vue project.
Huge thanks ! this was exactly what I needed ! the very bare bones approach to WS.
thanks bro I overcomplicated things but this really helped me understand
You are awesome, amazing and marvelous. This is a fantastic tutorial.
How isn't possible leave more than one like on this awsome video ?
Have been so much help, thanks a lot!
wow... that was smooth... it will help me tomorrow but thank you today.
Thank you, great work. It's very helpful
How do you use the same express port in ws?
how to authentication and authorization using jwt in websocket ws
Great tutorial. One question though, how can you send to specific client?
Websocket Update: Add another parameter, in ws.on('message'... called isBinary for sending to other clients excluding itself because they will be encrypted if I'm not mistaken. Kinda like this ws.on('message', function message(data, isBinary) { wss.clients.forEach(function each(client) { if (client !== ws && client.readyState === WebSocket.OPEN) { client.send(data, { binary: isBinary }); } });
very clear explanation.
For example if i want to send some data from server to client, but in a custom event. on the server side, in connection event i need to send the event, like wss.on('connection', function connection(ws){ ws.send('myCustomEvent', someData); }); and in the client side i just need to add an event listener to receive that custom event? socket.addEventListener('myCustomEvent', (data) => { console.log(data.data) })
very nice video short sweet and explained very well thanks :)
Thanks, great video!🔥 I use this in future video tutorial in my yt channel
Can We Uniquely Identify this client ? And Do some Action based on which client closed the Connection ??
Helped a Lot !!!!!
how can use this method to firebase web hosting
Before recording, I suggest increasing your vscode font to 17-20, it will really help us, thank you
bingo you’re awesome dude!
i tried the same code but in client side instead of showing hello from client1 its showing blob{size:19 type:" "} if u know how to solve the issue kindly let me know
Very useful, thank you!
@vuka951
3 жыл бұрын
Glad to hear that!
I like the console group chart!
Sir my websocket url require authentication how to connect. Please share some code or video
How can use it in real server hosting ??
Thanks a lot sir!
amazing man thanks alot :)
@vuka951
3 жыл бұрын
Glad it helped!
Nice video thanks
how do you save all connections I know when the user make a connection we can have an array such as const user = [] then we push each socket and user id from our front end, in case someone logs in to our server with jwt and gets the his user profile such as { id: xxxx, name: asss, email:add@hotmail.com} so we can push the user id or his email (unique) to that array along side the socket correct. can we store them in redis and if a connections is lost we can update that socket in redis ? or how do you go about implementing this thanks
great video
hello friend..i get the error when running a node index.js file const wss = new WebSocket.Server({ server:server }); ^ TypeError: WebSocket.Server is not a constructor
good video
why do you have to open the file directly? I want to navigate to port 3000 not open file with browser. I copied example from npm ws word for word and then copied the websocket browser example from mozilla developer word for word and it doesnt work. My browser goes into infinite load.
@ramsantosh6268
2 жыл бұрын
did you find the solution for opening the page in localhost:3000 (any port number)
wooooooza i like hardcore codding thou I am not that good so keep the good vibe going
I need help
good video. it could have been better if you used a bigger font, but great video anyways.
thank you
i like for the topics and explanation, i dislike for readibility, the text to small, you need to zoom it later
Next time please increase font size
What is the difference between ws and websocket ?? I'm really confused
@nclsDesign
3 жыл бұрын
Two different libraries but both with the dame basic function
@zsar_official
3 жыл бұрын
@@nclsDesign I figured, in a month
@thenextbigthing1393
2 жыл бұрын
@@nclsDesign I think its not dame.
@nclsDesign
2 жыл бұрын
@@thenextbigthing1393 Not the same but the SAME BASIC FUNCTION, as I said.
Bruh, next time add some zoom, I can't see that well