WEBVTT

1
00:00.880 --> 00:02.200
Hi everyone.

2
00:02.200 --> 00:12.160
In this video, let's talk a little bit of time to understand what's different between the HTTP protocol

3
00:12.360 --> 00:14.600
and WebSockets protocol.

4
00:15.360 --> 00:27.920
So protocol is just a collection of rules we must follow to talk with order from client and server.

5
00:27.960 --> 00:30.040
Okay, simple like that.

6
00:30.600 --> 00:43.120
Now let's understand the protocol HTTP protocol were designed for the request and response model.

7
00:43.880 --> 00:50.480
It means the HTTP protocol is clearly about one way data flow.

8
00:50.960 --> 00:51.480
Okay.

9
00:51.640 --> 00:53.160
Let me show you what I mean.

10
00:53.560 --> 01:02.160
For example we have a client client right here, maybe JavaScript browser Postman.

11
01:02.840 --> 01:04.360
It doesn't really matter.

12
01:04.480 --> 01:06.160
Or the mobile phone okay.

13
01:07.100 --> 01:09.060
And we have a server.

14
01:10.060 --> 01:11.020
The web server.

15
01:11.060 --> 01:11.540
Okay.

16
01:12.860 --> 01:13.940
What is the web server?

17
01:13.980 --> 01:22.940
Web server is just, uh, for example, like Apache Nginx or even Node.js.

18
01:23.100 --> 01:24.620
is also the web server.

19
01:25.660 --> 01:26.180
Okay.

20
01:26.940 --> 01:34.980
And in order to retrieve the data, the client should send the request.

21
01:35.420 --> 01:40.700
Follow the rule of HTTP for example like GET method.

22
01:42.860 --> 01:52.340
And only after the client send the request, the server will have the ability to respond back to the

23
01:52.340 --> 01:53.060
client.

24
01:53.300 --> 01:56.340
And you can see this here.

25
01:56.340 --> 02:01.780
And this here is clearly about one way data flow.

26
02:02.260 --> 02:05.500
We don't have the arrows like this right.

27
02:05.940 --> 02:13.000
Because the HTTP is a one way data flow

28
02:15.320 --> 02:24.640
It means only the client can send a request and only the server can respond.

29
02:25.600 --> 02:26.160
Okay.

30
02:27.320 --> 02:33.320
The server cannot respond without client send request.

31
02:34.720 --> 02:35.000
Okay.

32
02:35.040 --> 02:36.720
I hope you clearly about us.

33
02:38.280 --> 02:45.520
And so how about the WebSockets protocol?

34
02:45.880 --> 02:52.400
WebSockets protocol is designed for true bi directional communication.

35
02:53.160 --> 03:00.520
It means the server and client can be send the data.

36
03:00.720 --> 03:01.280
Okay.

37
03:01.880 --> 03:06.080
maybe we have a data we want send back into the server.

38
03:06.480 --> 03:11.040
And server can send back it into the client.

39
03:11.280 --> 03:11.840
Okay.

40
03:12.200 --> 03:16.680
That's about the advantage of the WebSocket.

41
03:17.200 --> 03:23.510
Now let's imagine we want to build some chat application.

42
03:23.870 --> 03:24.230
Okay.

43
03:24.270 --> 03:30.950
For example, we have some user interface over here with some chat.

44
03:32.670 --> 03:38.390
Now how we can build that with the normal HTTP.

45
03:40.550 --> 03:40.990
Okay.

46
03:41.030 --> 03:44.910
We don't need to use the WebSocket right now.

47
03:45.670 --> 03:53.190
Let's see how we can build a chat application using the HTTP protocol.

48
03:53.870 --> 04:04.750
Well for example when I want to type some text and I will click in this button to send the text.

49
04:07.670 --> 04:08.350
Over here.

50
04:08.990 --> 04:14.990
So how another client can see the text over here.

51
04:15.350 --> 04:15.910
Okay.

52
04:16.110 --> 04:17.190
How the client.

53
04:17.870 --> 04:25.650
Well in order to show the text right here, the client right here must be make a HTTP request into

54
04:25.650 --> 04:31.490
the server, and after that the server will respond back to the client.

55
04:31.930 --> 04:32.450
Okay.

56
04:35.170 --> 04:44.850
For example, in the second time, if I type something and I click send one more time right here, clearly

57
04:45.450 --> 04:54.450
the client right here doesn't have a new message because the client right here doesn't make any request.

58
04:54.530 --> 04:55.050
Right.

59
04:55.850 --> 04:56.250
Only

60
04:58.290 --> 05:08.090
If the client right here make a new request, it will see the new message.

61
05:08.490 --> 05:13.010
You can see this is the limitation of normal HTTP, right.

62
05:13.970 --> 05:19.250
So right now if you don't understand this totally okay.

63
05:19.490 --> 05:27.410
In the next video I will show you how we can build the chat application using the normal HTTP protocol.

64
05:29.170 --> 05:30.610
I will see you in the next one.