Hi everyone.
In previous video we already talked about TCP Handshake.
And in order to send a request using the http, we should established the TCP collection first.
And in order to establish the TCP, we will use the three way handshake.
Okay, I already showed in previous video.
And right now in order to open the WebSocket connection, we should use the http handshake also.
So let me explain for you right here.
The reason we should establish the http handshake because the WebSocket is designed carefully to work with
HTTP
Okay.
Let me show you what I mean.
Because the WebSockets in a protocol and HTTP also the protocol.
So we need some way to switching from the HTTP into the websockets
Right.
And that process we will call the HTTP handshake
Let me show you what I mean.
Firstly we need to send the http request into the server.
And of course right now the TCP connection already established right.
We will send the HTTP request into the server.
Hi.
Server, please switch from HTTP into the Websockets and server will respond back.
Okay, I already switched and right now we will have a two way directional.
Okay, we will completely become a websockets right now.
Very very cool.
And this process right here we will call the HTTP handshake.
Let me show you in practical.
Client it will send the request into the server.
You see the WebSocket API from the browser like WebSocket.
And it will put some URL.
Okay.
It will put some URL and we will send the normal http request into here.
Inside here what we need to do.
What we send during the request of the client.
Well, we will send something called "upgrade".
We will tell.
Upgrade into the WebSocket.
Okay.
We will tell the server.
Please.
Upgrades the HTTP into the WebSocket.
And after we send the request in the server we will send the server will respond with the status 101.
In order to switch in protocol and from now we will achieve the WebSocket protocol.
Okay.
That's it, that's about the.
HTTP handshake process.
Well let me show you in practical.
Right now I will go to the WebSockets right here.
And I will click something.
And inside the tool right here we have something called WebSockets Echo Server.
We can easily do that right now.
We don't need to
Set up server or something like that.
I just want to demo for you.
The HTTP handshake, inside a network that I will click on filter.
Filter over here and click on the WebSocket and WebSocket.
I will clear everything and inside the console I will establish the socket using a new web socket.
And we need to put the url of the WebSocket server.
Right now I will copy paste this URL right here and I will put that over here.
And I will enter.
After that we will go back to the network tab and click on this thing right here.
Now you can see.
Right now we will send the header using the collection will be "upgrade" and we upgrade into the
WebSocket protocol.
And of course, it have some WebSocket related right now.
But I don't care about that right now.
Okay.
The only thing we care right now is the "upgrade" will be the connection with this field.
We will tell the server please update from the HTTP into the WebSocket protocol.
And after that we will respond.
Okay.
We will respond back into the 101 will be switching protocol.
And right now we will have the ability to talk from the client with the server using the WebSocket protocol.
Okay.
That's about to be HTTP handshake.
So I hope you are very clear right now.
I will see you in the.