0:00:24
what is going on guys welcome back to
0:00:27
another session of buildbreaking fix
0:00:29
brought to you by the raw coders
0:00:32
yes and you might be observing that um
0:00:36
one of the raw quarter i
0:00:39
couldn't make it so
0:00:44
and which is why due to his work
0:00:46
commitments uh he can't really make it
0:00:50
today um we really miss you kartik and
0:01:02
before uh we move on i just want to do
0:01:08
of the country so here goes
0:01:14
i begin today by acknowledging the
0:01:16
traditional custodians of the land on
0:01:18
which we gather today and pay my
0:01:20
respects to the elders past present and
0:01:23
future i extend their respect to
0:01:25
aboriginal and torres strait islander
0:01:31
all right perfect so
0:01:33
now that is all done um
0:01:37
recap what we did yesterday so what we
0:01:41
did was we were researching how to
0:01:45
um integrate socket or websocket into
0:01:56
which is done in express app all right
0:02:00
um because it is my first time working
0:02:04
technology um we will have to
0:02:07
keep on researching and learning and
0:02:09
then learn build break and fix if you
0:02:12
know what i mean all right
0:02:15
so yeah without further ado let's get
0:02:19
right cool so i'll just share my screen
0:02:22
really quick and we could take it from
0:02:29
all right just closing all the
0:02:37
right uh this is my screen and
0:02:51
let's share the entire content
0:03:04
the websockets actually work
0:03:09
uh there is another technology called um
0:03:12
socket io so i do want to check what's
0:03:14
the difference between
0:03:16
socket io and websocket so let's do that
0:03:27
actually versus socket io
0:03:31
what is the difference between these
0:03:35
this seems to be a pretty good good
0:03:42
versus socket io comparison was created
0:03:45
but okay that's just saying what it does
0:03:50
so it's just comparing
0:03:54
aspects of it so time to hello world
0:03:58
which is that one we don't really need
0:04:02
but i just want a bit more detail
0:04:08
and i would also have to keep an eye on
0:04:10
the comments in case
0:04:16
some comments from our lovely viewers
0:04:35
dashboard now console
0:04:38
is a few so what does he actually do
0:04:45
much like the solution the documentation
0:04:50
lightweight you have an excellent
0:04:55
guide that requires no prior it's okay
0:05:01
that turns of code snippets okay it's
0:05:05
the features of it and how is it to get
0:05:11
um sock io does not provide a developer
0:05:13
console here which is fine
0:05:18
you can see wow this
0:05:21
has that one okay the amazon api gateway
0:05:27
uh dock provides separate reference
0:05:30
pages for each of the
0:05:37
each of the programming languages the
0:05:41
largely consistent
0:05:44
thank you jesse welcome good to have you
0:05:58
so we want to integrate
0:06:00
socket i however if you do socket io
0:06:08
impossible to use sokkaya with
0:06:14
right that seems like a pretty good
0:06:22
aws release support for websocket
0:06:26
for iot is very easy to use as a problem
0:06:30
some message system for 47
0:06:35
function hp request and receive a
0:06:37
websocket message on a client i browse
0:06:42
pack mpm package that handles websocket
0:06:47
to mqtt server from the front end
0:06:58
check out mqtt declined i don't think
0:07:01
that lambda is going to work for the
0:07:03
case you described it that in today
0:07:09
the lambda function can only
0:07:11
run for maximum of 15 minutes
0:07:16
furthest since you are charged
0:07:20
per 100 millisecond of the function
0:07:25
runtime this will probably cause because
0:07:34
so i guess we will have to
0:07:37
do websockets because apparently we
0:07:42
socket io with lambda
0:07:47
as lambda is actually interacting with
0:07:52
cool so let's figure out um
0:08:06
flip sockets can i use web socket uh-huh
0:08:22
in api giveaway you can create that
0:08:27
websocket api as a state full frontend
0:08:33
for lambda or dynamic before all four
0:08:45
api invokes your backend based on the
0:08:52
it receives from a client
0:09:01
this is what we want there's three
0:09:04
predefined room okay so these are the
0:09:06
basics of websocket apis
0:09:21
unlike the rest api which receives
0:09:26
uh receives and responds to request
0:09:30
web api sports a two-way connection
0:09:33
between client apps and your backend
0:09:35
right so this is a difference between
0:09:48
rest api receives and responds to
0:09:53
websocket is supposed to link to a
0:09:56
communication between
0:09:58
between clients apps
0:10:04
the back-end can send callback messages
0:10:08
connected clients right in your
0:10:10
websockey if your incoming json message
0:10:20
routes that you you configure
0:10:24
non-json mess okay so incoming json
0:10:28
messages are directed to the backend
0:10:31
integration based on routes
0:10:34
that we we configure
0:10:38
messages are directed to our default
0:10:43
route that you configure right okay
0:10:46
a route includes a root key
0:10:49
okay i'll probably
0:10:52
have to have an example for it
0:11:02
which is the which is the value that is
0:11:10
once a root selection expressed is
0:11:15
which is the value that is expected okay
0:11:18
once the rule selection is
0:11:25
actually i'm gonna go and get um
0:11:30
go to websocket appear in
0:11:35
youtube and check that
0:11:40
i'll build real camera huh
0:11:43
create websocket using fps your service
0:11:46
yeah probably this one
0:11:50
and how to create websockets
0:11:54
using api gateway and
0:12:02
okay let's check this one out
0:12:07
what's up guys i'm chirag and welcome to
0:12:11
and as always i hope that you are
0:12:13
finding the tutorials helpful
0:12:15
right so today i am here to start a new
0:12:22
right and i will try to keep the
0:12:25
tutorials as simple as possible
0:12:29
welcome to part one of the tutorial
0:12:31
series on amazon website api gateway
0:12:50
now interactive communication possible
0:12:53
between the client and server
0:12:55
so here client can be the web browser
0:12:59
websocket api is ideal for applications
0:13:04
real-time dashboards
0:13:07
and notification system collaborative
0:13:09
platforms or it can be multi-player
0:13:16
we will start with the basic difference
0:13:17
between rest api and websocket api right
0:13:20
so how they works and how they create
0:13:23
the connection right so at the very high
0:13:27
so i have come up with this diagram at
0:13:29
the very high level so basically in rest
0:13:33
the client initiates the request with
0:13:35
http methods like get post delete
0:13:40
right and rest api will react
0:13:42
accordingly based on the integration it
0:13:46
with that method right
0:13:51
client sends the request and based on
0:13:53
the method or the http method the server
0:13:56
will perform the action and
0:13:58
send out some response back to the
0:14:00
client right so that's how a sdk works
0:14:03
it's kind of a request response model
0:14:08
rest api is unidirectional in nature and
0:14:12
probably it is not suitable for
0:14:14
real-time applications like chatbot and
0:14:17
few of the application that i just
0:14:19
mentioned earlier right
0:14:21
so that's a rest api
0:14:24
whereas in web socket api the client
0:14:26
application connects to the websocket
0:14:29
api by sending a websocket upgrade
0:14:31
request right so client will send the
0:14:34
http upgrade request to the server and
0:14:36
in response the server will send the
0:14:38
acknowledgement packet and if everything
0:14:41
is successful then the connection will
0:14:42
be open between client and server
0:14:45
right and once the connection is open
0:14:48
the bi-directional communication or the
0:14:52
exchange of messages can take place uh
0:14:54
between client and server
0:14:58
when i say it's bi-directional which
0:15:02
two-way communication can happen that is
0:15:04
from client to server and vice versa as
0:15:07
possible whereas in rest api
0:15:10
it is unidirectional in nature right
0:15:14
so basically websocket api uses a single
0:15:17
tcp connection uh for
0:15:21
transfer of the messages between client
0:15:24
so and finally uh for closing the
0:15:29
any of the entity can close the
0:15:30
connection so it can be a client or it
0:15:32
can be a server right so basically it
0:15:34
can be a time out or
0:15:36
client close the connection right so
0:15:39
that's how the closing of connection
0:15:40
takes place in websocket api
0:15:46
this is kind of the very basic
0:15:47
difference between rest api and
0:15:49
websocket api right so
0:15:53
now we will move back to aws management
0:15:55
console and we will jump to the api
0:15:59
because as i said we are going to create
0:16:02
the websocket api in this tutorial
0:16:04
right so once you are within api gateway
0:16:07
click on create api from the top right
0:16:12
now here we have three option we are
0:16:14
going to select websocket api
0:16:20
build now give it a name so i will say
0:16:32
and then we have route selection
0:16:45
now that we know kind of a really basic
0:16:50
uh and the difference between
0:16:52
websocket api and the restful api let's
0:16:57
and try and create a websocket api in
0:17:02
sam template so as
0:17:06
infrastructure as code all right
0:17:10
hey hey gizer what's happening gag dev
0:17:15
what's happening so the difference from
0:17:18
what i've understood the video that i
0:17:20
was watching on a really high level
0:17:23
is um the rest api is
0:17:27
synchronous so it's
0:17:30
uh it sends a request
0:17:32
and then it receives the response
0:17:41
webs socket it's bi-directional so
0:17:45
um once the handshake is made between
0:17:48
the client and the server
0:17:52
communications are from
0:17:57
um hope um my understanding was right um
0:18:04
if you don't think then i would love to
0:18:09
as in um improve on that
0:18:14
cool so now let's actually
0:18:20
websocket will be at the back end so we
0:18:23
have to open our back end one
0:18:27
and repost so let's go into that one am
0:18:30
i already sharing my screen
0:18:40
open our back and repo
0:18:46
actually i need to check how to create a
0:18:51
websocket sam template create
0:19:12
announcing websocket yeah
0:19:15
that's fine how to create a websocket
0:19:19
you choose same api gateway for both
0:19:25
http lambdas yeah i think that would
0:19:38
one possible solution is to put behind a
0:19:41
cloudfront distribution
0:19:43
i'll do this properly since i already
0:19:47
no that's that's not
0:19:52
this is relevant section for my okay
0:19:55
um i've been using aws for websocket api
0:20:00
that that's working well today i needed
0:20:03
to add an http okay cool so we already
0:20:06
have this but we need
0:20:12
so this is how it's done basically and
0:20:17
websocket api used this for various web
0:20:19
circular lambda works
0:20:22
like a charm aha interesting
0:20:29
have to keep on the
0:20:49
we have our api gateway
0:20:51
which is over here
0:20:53
now we need to create our
0:21:05
all right so let's do this
0:21:14
um so websocket api
0:21:24
okay had a function yeah cool so this
0:21:27
would come up over here so web
0:21:43
and then i'm gonna do a type api gateway
0:21:48
why does he have a version two here
0:22:08
i'll just copy and actually know and
0:22:10
don't want to copy and paste anything
0:22:32
that would be properties
0:22:43
simple relay websocket so properties
0:23:19
okay and then root selection expression
0:23:26
selection expression
0:23:37
so what would be the div
0:23:45
let's actually have a look if this
0:23:47
actually works for us
0:23:50
all right so i'll just do some build
0:24:05
miss us in the chat
0:24:18
okay so it's still building which is
0:24:20
good and it's built successfully
0:24:25
that seems positive
0:24:34
and use our profile
0:24:41
uh profile scrambler
0:24:45
all right there we go
0:24:47
yeah that's my stack i'm happy with that
0:24:52
yes save arguments to configuration file
0:25:11
okay so it's just initiating the
0:25:15
and now it will deploy the changes see
0:25:18
if we messed up anyway
0:25:21
if we have it won't upload this
0:25:24
we won't deploy the changes successfully
0:25:32
it's creating the websocket api now
0:25:40
interesting so it's actually created it
0:25:47
okay so let's go to our lambda
0:26:03
no account id what was the account id
0:26:06
ouch i do not know
0:26:14
let's access that from the root user
0:26:20
and i'm gonna just
0:26:22
stop my screen sharing because i need to
0:26:38
okay let's stop my screen share to get
0:26:48
let's get that one
0:26:51
where is my password
0:26:53
i need my password
0:26:57
my password is over
0:27:08
there we go i found my password
0:27:15
if we enter the password in the root
0:27:20
account there i got my
0:27:27
i need to go to imuses
0:27:34
go to my users and then get the account
0:27:39
now that should be very good to go
0:27:43
yep found it there we go that's my
0:27:48
i don't want the entire bit
0:27:58
giving me the entire bit that's
0:28:00
interesting i don't really want the
0:28:03
or i can just copy it from here
0:28:27
okay here we go we are in so now come
0:28:31
back and share my screen
0:28:36
where's my screen gone yeah here we go
0:28:44
there we go we are back in action
0:28:49
what we needed to do was
0:28:52
um check if it's created our websocket
0:29:04
and this is our stack
0:29:14
okay that's how the word function
0:29:18
it's gonna be api scroll on vpa
0:29:22
api get redeployment is
0:29:27
uh here we go this is our
0:29:31
websocket api which is brilliant cool so
0:29:34
let's open that and
0:29:36
check what it says
0:29:38
okay so it's got free connect rookie
0:29:42
okay i need to learn the terminology as
0:29:49
cool so now that this is done
0:29:53
what we need to do is we need to
0:30:00
we need to learn is terminology
0:30:09
cool so go back in the
0:30:19
by mapping the value i've done that you
0:30:22
know it sounds confusing uh but it will
0:30:27
part two of this tutorial series right
0:30:29
so here uh we are going to mention
0:30:32
dollar request dot body dot message or
0:30:37
dollar.request.body.action or any key
0:30:39
you want to mention right so it's going
0:30:51
or you want to keep it as action then
0:30:54
you can keep it as action
0:30:57
you want and then you can add a
0:31:00
if you want and once you're done with
0:31:02
that click on create api
0:31:07
right and here we have successfully
0:31:09
created the websocket api right
0:31:12
so here in the left panel
0:31:17
so here we have route selection
0:31:19
expression that we have defined while
0:31:21
creating these objects okay what exactly
0:31:30
what exactly is the um
0:31:37
root selection expression i need to have
0:31:43
expression the root selection expression
0:31:45
tells api gateway which route
0:31:48
to call when a websocket message is
0:31:54
the value found at the evaluated
0:31:57
expression or to the root key
0:32:04
so the rule express the rules slash
0:32:10
api gateway which route to call
0:32:13
so in our terms it would be the route
0:32:16
get proposing delete probably
0:32:28
by mapping the value found at the
0:32:31
evaluated expression
0:32:45
you might explain us later in the video
0:32:48
right and then we have these routes that
0:32:50
is connect disconnect or default so for
0:32:52
example client is trying to connect to
0:32:54
the websocket api then connect route
0:32:58
and then when client is trying to
0:33:03
client is disconnected from the
0:33:05
websocket api then disconnect route will
0:33:08
call and any other request that might
0:33:10
come goes to default and we can add
0:33:13
another route keys over here right
0:33:16
so at this point of time all the routes
0:33:18
are disabled we have to click on it to
0:33:21
add the route but we are not going to do
0:33:23
that now uh i will take you through
0:33:26
routes in the next tutorial right
0:33:30
basically at the very high level
0:33:32
route selection expression right now is
0:33:35
requested body dot action right so
0:33:37
basically this expression
0:33:38
tells api gateway how to determine which
0:33:41
route or which action to perform right
0:33:46
now for example we have another key
0:33:50
so so now if i go ahead and pass action
0:33:56
then it will evaluate the expression and
0:33:58
it will determine that
0:34:00
message route should be called right so
0:34:01
that's how our route selection
0:34:03
expression will work but we will come to
0:34:05
that in the next tutorials called right
0:34:06
so that's evaluate the expression and it
0:34:09
will determine that
0:34:10
message route should be called right so
0:34:12
that's how our route selection
0:34:13
expression will work but we will come to
0:34:17
it will evaluate the expression and it
0:34:19
will determine that
0:34:20
message route should be called right so
0:34:22
that's how our route selection
0:34:24
expression will work but we will come to
0:34:25
that in the next tutorial right
0:34:29
so now moving along
0:34:30
then we have stages so
0:34:32
these are going to be our deployment
0:34:34
state so it can be a development it can
0:34:37
be developed broad
0:34:38
or testing or whatever stage
0:34:41
as per the requirement we want to create
0:34:46
and then we have authorizers so we can
0:34:49
create a new authorizer that is based on
0:34:51
the lambda function right so
0:34:54
that's authorizers then we have models
0:34:56
so basically models represent the data
0:34:58
structure of a method request or
0:35:00
response payload right so you can click
0:35:03
on create and define the model schema
0:35:06
and then we have dashboard so here you
0:35:09
can get some insights regarding message
0:35:11
count connection count and whatnot right
0:35:14
so right now we don't have uh any
0:35:16
anything over here because we have just
0:35:19
and then we have this endpoint type as
0:35:21
regional and the api keys so that's uh
0:35:24
so this is a very high level about a
0:35:26
websocket api right so i know
0:35:28
uh routes might sound a little confusing
0:35:31
at this point of time but the idea will
0:35:33
get clear in the next tutorial right
0:35:35
because the next tutorial is going to be
0:35:41
so well uh this is all i wanted to cover
0:35:44
in this tutorial right so as i said in
0:35:46
the next tutorial we will create crowds
0:35:49
and i will take you through
0:35:52
what's up guys i am chirag and welcome
0:35:54
to part two of the tutorial series on
0:35:56
amazon websocket api gateway tutorial
0:35:59
in the previous tutorial we had created
0:36:01
the websocket api as you can see on my
0:36:04
screen and now in this tutorial we will
0:36:07
so first we will try to understand what
0:36:09
actually roots is and then probably we
0:36:11
will move on to the configuration and
0:36:13
the backend integration uh with the
0:36:15
respective routes that we have on the
0:36:19
so uh i am within the api gateway uh
0:36:22
that i have created in the previous
0:36:24
tutorial right and i am within roots now
0:36:26
here we have three option uh that comes
0:36:28
by default that that is connect
0:36:31
disconnect and default route so right
0:36:34
disabled right to add those routes we
0:36:36
have to click on it and then it will
0:36:38
give us the option to integrate the
0:36:41
backend integration can be a lambda
0:36:43
function or the http endpoint or
0:36:47
any amazon service or it can be a mock
0:36:52
apart from that we have dollar request
0:36:54
dot body dot action so this is the route
0:36:57
selection expression that we have
0:36:59
configured in the previous tutorial
0:37:01
so uh here we are going to start with
0:37:03
the assumption that we have configured
0:37:06
routes that is connect disconnect and
0:37:09
default and all these three routes are
0:37:10
integrated with the
0:37:12
lambda function as a part of the backend
0:37:17
so uh having said that and with that
0:37:20
assumption we will move on to this
0:37:26
as i said we have connect
0:37:28
default and disconnect root as
0:37:31
configured right so basically what will
0:37:34
api gateway will call the connect route
0:37:37
when the persistent connection between
0:37:39
the client and uh websocket api is being
0:37:42
initiated right so at the very first
0:37:44
time uh when the connection is being
0:37:47
persistent between client and server the
0:37:50
connect rule will get executed
0:37:54
and once the connection is open we will
0:37:58
functionality for bi-directional
0:38:02
so so once it is opened and the connect
0:38:06
route is executed we will have this
0:38:07
option right so that comes as a part of
0:38:10
the route selection expression
0:38:14
regarding disconnect route api gateway
0:38:16
calls the disconnect route when the
0:38:18
client or the server disconnects from
0:38:24
api gateway will try to execute the
0:38:26
disconnect route when
0:38:28
when there is a termination of
0:38:30
connection uh either from the client
0:38:32
side or the server side right so it can
0:38:36
manually terminating the connection from
0:38:38
the client side right so at that point
0:38:40
of time uh disconnect route will get
0:38:43
now uh having said that uh we have
0:38:46
opened the connection and and we are
0:38:48
here right so now here we have route
0:38:50
selection expression
0:38:52
right uh just to give you an idea so let
0:38:55
me uh change this it's action over here
0:39:03
so now we have route selection
0:39:04
expression as request dot body dot
0:39:06
action right and now the client will
0:39:08
send the json payload right
0:39:11
that is action column message so this is
0:39:14
the key value pair
0:39:16
now once the payload is sent what route
0:39:18
selection expression will do is it will
0:39:20
evaluate that payload so here
0:39:25
represent this key within the payload
0:39:27
right so it will try to look for the
0:39:30
action as a key within that payload
0:39:32
if it is there then it will grab the
0:39:35
value of that key so basically in our
0:39:38
case right now its message
0:39:40
now once route selection expression will
0:39:42
have that value as a message it will
0:39:43
look for the possible routes uh with the
0:39:48
so here we don't have any other routes
0:39:50
except the default one so what it will
0:39:52
do is it will forward or it will pass on
0:39:56
that request to the default route
0:39:59
because it is unable to find the message
0:40:01
route now for example uh we have
0:40:04
another route saying
0:40:09
so here we don't have any other routes
0:40:13
a payload so here um this action uh
0:40:17
represent this key within the payload
0:40:20
right so it will try to look for the
0:40:22
action as a key within that payload
0:40:25
if it is there then it will grab the
0:40:27
value of that key so basically in our
0:40:30
case right now its message
0:40:32
now once route selection expression will
0:40:34
have that value as a message it will
0:40:36
look for the possible routes with the
0:40:40
so here we don't have any other routes
0:40:43
except the default one so what it will
0:40:45
do is it will forward or it will
0:40:48
pass on that request to the default
0:40:51
because it is unable to find the message
0:40:57
another route saying
0:41:01
message over here right
0:41:03
now in this case what will happen uh
0:41:06
client will send the payload that is
0:41:07
action message it will look for action
0:41:09
within that payload so it have as a key
0:41:12
and once it identify the key it will
0:41:15
grab the value of that and it will look
0:41:18
for the possible road so now we have
0:41:20
message as a route so it will pass on
0:41:24
this route right and
0:41:27
this route will have its back-end
0:41:28
integration so let's assume uh it also
0:41:30
have the lambda function as a backend
0:41:34
now uh for example uh if i'm passing the
0:41:43
so now in this case uh what will happen
0:41:47
it will first evaluate this json it will
0:41:50
look for the action uh as a key and it's
0:41:52
unable to find it so what it will do is
0:41:54
it will by default pass on this uh
0:41:56
request or payload to the default route
0:41:59
right because it is unable to find the
0:42:02
now same goes for if i say
0:42:12
so i'm just trying to give you an
0:42:13
example so now the payload is action as
0:42:17
now route selection expression will
0:42:19
evaluate this payload it will look for
0:42:21
action within that payload
0:42:24
and once it is successful it will grab
0:42:25
the value of that key that is held in
0:42:28
this case now it will look for the
0:42:30
possible routes and it will try to match
0:42:33
help with the possible routes right so
0:42:35
here we have message and default
0:42:38
right so what it will do is it is unable
0:42:40
to find the help route so it will by
0:42:42
default pass on this request to the
0:42:44
default route now in case uh if we go
0:42:48
ahead and create the default route sorry
0:42:50
not default help route
0:42:55
then instead of passing or forwarding
0:42:58
to the default route it will pass on
0:43:00
this request to the help rule and it
0:43:03
will have some backend integration let's
0:43:06
it has lambda function right so this is
0:43:09
how uh it will evaluate the payload
0:43:14
so uh for example a client can pass
0:43:20
so instead of uh this json message
0:43:22
client can pass non-json messages right
0:43:28
i can say something like this
0:43:31
uh text payload for example right
0:43:35
so basically uh non-json messages are
0:43:37
directed to the default root that you
0:43:39
so because here it's unable to find any
0:43:43
key value pair right so that's how route
0:43:45
selection expression will trade the
0:43:47
non-json uh payload right
0:43:50
or the non-json messages
0:43:57
so let's change this once again as
0:44:03
are directed to the default root that
0:44:04
you configure right so because here it's
0:44:07
unable to find any
0:44:10
key value pair right so that's how route
0:44:11
selection expression will trade the
0:44:16
or the non-json messages
0:44:23
so let's change this once again as
0:44:32
so at high level what will happen is the
0:44:34
service will use this route selection
0:44:36
expression to identify the keys which
0:44:39
exactly matches with the route if
0:44:42
the key does not match the route or if
0:44:44
that route doesn't exist then it will by
0:44:46
default forward that request or the
0:44:48
forward that message to the default
0:44:53
and for example uh if no routes match
0:44:55
the evaluated value and we even don't
0:44:58
have the default route right so we don't
0:45:00
even have this default route then what
0:45:02
it will do is the service will return
0:45:04
the error right so it's a good idea to
0:45:07
always have the default route to uh
0:45:10
pass on or to send the response to the
0:45:13
client saying that it's
0:45:15
invalid message or whatever right
0:45:19
at the high level that's how uh this
0:45:30
there's some comments so devs asking why
0:45:37
the reason we're doing websockets is
0:45:39
because we want as a multiple
0:45:42
users to be able to interact with the
0:45:45
which means that the
0:45:48
the communication has to be
0:45:51
if them if that makes sense
0:45:56
they would probably
0:45:58
be able to um interact with the board
0:46:14
alexander cook um good to have you i'm
0:46:17
knowing entirely sure what you said
0:46:20
there so you might want to
0:46:26
so let's go back to
0:46:32
it's an explanation
0:46:35
so here i have mentioned a few points so
0:46:37
connection is open so once the
0:46:38
connection is persistent the connect
0:46:40
route will get triggered once the
0:46:43
connect route is triggered we will have
0:46:45
the bi-directional uh messages uh
0:46:47
feature right so we can send a message
0:46:50
from client to server and server to
0:46:53
client and vice president
0:46:56
and then once the collection is
0:46:58
and then once the connection is closed
0:47:01
the disconnect route will get triggered
0:47:04
now let's go back to api gateway so here
0:47:07
we are going to configure connect and
0:47:09
disconnect route and we will not
0:47:11
configure default router we will come to
0:47:12
that at later point of time right in
0:47:14
some other tutorials
0:47:17
so now uh we will require two lambda
0:47:19
function and the iam rule so we will
0:47:22
start with the iam rule so navigate to
0:47:26
iam management console
0:47:29
once you are there click on rows from
0:47:30
the left panel and say create row
0:47:33
select lambda as a service because we
0:47:37
just bear with me guys i need to get
0:47:41
get that in my garlic so i'll be right
0:48:41
all right back into action
0:48:45
function and then click on next
0:48:48
here we will attach aws any comments so
0:48:51
far no we don't have any comments
0:48:56
let's jump back in the lambda
0:48:59
execute permission right so by default
0:49:02
it will have uh s3 access and the cloud
0:49:06
the function and the iam role so we will
0:49:09
so now uh we will require two lambda
0:49:12
function and the iam rule so we will
0:49:16
iam rule so navigate to iam management
0:49:21
once you are there click on rows from
0:49:23
the left panel and say create rule
0:49:25
select lambda as a service because we
0:49:27
are creating this rule for the lambda
0:49:29
function and then click on next
0:49:31
permission here we will attach aws
0:49:35
execute permission right so
0:49:38
by default it will have s3 xs and the
0:49:41
cloud watch access
0:49:42
then click on next tags
0:49:45
enter tag if you want then finally click
0:49:47
on preview and give it a role name so i
0:49:50
will say web socket
0:50:09
maybe i will say websocket underscore
0:50:13
right and click on create role
0:50:17
now once the iam role is created
0:50:19
navigate to lambda management console so
0:50:21
here we are going to create
0:50:23
two lambda function one for
0:50:26
the connect root and one for the
0:50:28
disconnect group right
0:50:32
so once you are within lambda management
0:50:33
console click on create function from
0:50:38
corner give the function
0:50:42
right okay so now what i need to do is i
0:50:48
the lambdas for the connect and the
0:50:59
look we can create that over here
0:51:23
okay and this would be
0:51:30
actually what was it here type
0:51:56
and what do i need
0:52:04
this is what would be a bit tricky
0:52:20
honest i don't even know what the
0:52:21
property should be
0:52:27
so the code will be in scrum leader apa
0:52:31
folder would be right
0:52:44
that needs a space
0:52:48
so it's in that folder and which one
0:52:51
would it be handling
0:53:01
right and i will select runtime as
0:53:05
within permission use existing role
0:53:08
select the role that we have just
0:53:09
created that is web socket under
0:53:12
lambda and say create function
0:53:19
now go back to lambda management console
0:53:24
let's do in this way so
0:53:30
function to connect
0:53:34
a client to web socket
0:53:40
right there we go we of course some
0:53:42
videos how to build a real
0:53:45
yeah that could be
0:53:54
uh build a websocket service uh-huh
0:53:58
why serverless okay don't need that one
0:54:02
websocket clients if you get right
0:54:07
adding lambda roll which is fine
0:54:11
adding custom config
0:54:19
so ah this is serverless.yml
0:54:26
to build a real-time using api
0:54:30
yeah this one should be good for us
0:54:34
websocket concepts
0:54:38
choose when the okay that one
0:54:43
don't really need to know that
0:54:46
uh device connected
0:54:52
so yeah i need this i need to check how
0:54:59
okay disconnect and
0:55:01
messages your connection id from
0:55:06
create websocket api
0:55:09
yeah that's fine no problem
0:55:13
uh create before adding the rule
0:55:15
according to the above we need to do
0:55:18
okay click click lambda okay so we need
0:55:21
to create all these lambdas
0:55:24
right so first let's create diamond tv
0:55:31
right up basically it's done okay no we
0:55:35
need to basically create another table
0:55:45
in which we will save all the connection
0:55:51
all right i didn't know that
0:55:58
less okay so connection
0:56:02
db we need to create
0:56:09
we need to create another one
0:56:11
so let's call this
0:56:22
what did he call that
0:56:36
actually would i need that
0:56:39
yes i would need another table for users
0:56:42
to determine which users are actually
0:56:45
connected to the websocket and then
0:56:49
we need to whenever the
0:56:51
the board has been
0:56:53
changed all those users
0:56:55
which have the connection id
0:56:58
and they're still connected
0:57:01
they would get the updated
0:57:33
so the attribute name would be um
0:57:47
next you know again that would be
0:57:49
basically a string
0:57:58
and i would need another one
0:58:53
okay connection id
0:58:55
and attribute would be status
0:59:04
someone is still in a connection or
0:59:09
um as anyone commented uh
0:59:19
good to have you mate
0:59:23
yes i am so i managed to i'm following
0:59:26
this really useful tutorial on youtube
0:59:32
one and is basically uh
0:59:35
learning as in what's the difference
0:59:40
restful api and web socket
0:59:44
and also i managed to
0:59:46
create a websocket api and now i'm
0:59:59
in the process of uh
1:00:02
getting all the pre
1:00:06
done which is apparently
1:00:13
lambda functions so i'm just
1:00:18
another dynamo db um in our sam template
1:00:26
it's fun stuff made
1:00:28
definitely fun stuff and
1:00:30
wow the time really flew
1:00:34
right looks like we can
1:00:37
leave you at this point
1:00:47
okay yeah you watched another video
1:00:49
which was very up which yeah i think
1:00:52
there are loads of videos which are
1:00:55
really helpful and as many resources on
1:01:02
can't wait to get this
1:01:04
working because it's
1:01:06
at the moment it's kind of a steep
1:01:08
learning curve for me because
1:01:11
i haven't worked with
1:01:22
tuning in been a pleasure having you
1:01:24
guys and um yeah what will you do with
1:01:27
dynamodb so apparently um i need a way
1:01:31
to figure out as in which
1:01:38
or devices will be connected to this
1:01:47
and for that one i i need to store all
1:01:55
ids and then database and with the
1:01:59
status of active on
1:02:03
when i see that as jesus has kind of
1:02:10
he won't get the message that others
1:02:14
yeah yeah connection 90
1:02:17
yeah yeah pretty much right cool guys um
1:02:24
evening or wherever you are
1:02:29
afternoon or good night and we'll see
1:02:32
you back here tomorrow with same place
1:02:36
same time and the same task yes you
1:02:40
all right guys cheers bye