How to build a chat using Lambda + WebSocket + API Gateway? (nodejs)

Поділитися
Вставка
  • Опубліковано 7 лип 2024
  • ⚡️ Blog post and source code: www.undefinedapps.com/post/la...
    In this video we build a real-time chat app (like slack) that uses websockets backed by an AWS lambda function and Amazon API Gateway. The app sends JSON over the websocket to deliver the chat messages and notifications in real time, over a two-way communication line, to all the users of the chat.
    0:00 Demo and Description
    0:34 Setting Up API Gateway
    2:22 Creating the Lambda Function
    4:12 Writing the Backend Code (javascript/nodejs)
    9:15 Testing the WebSocket Using wscat
    14:44 The Chat Client UI Overview (react+hooks)
    17:47 Writing the Frontend Code (javascript/typescript)
    23:54 Trying What We Built by Connecting to the Chat as 4 Different Users
    The client is written in react (with hooks) and uses the WebSocket api that is available in all the modern browsers. The backend is serverless and uses API Gateway + AWS Lambda with javascript/nodejs.
    ⭐️ Subscribe for more content: newsletter.undefinedapps.com/
    #WebSocket #Lambda #ApiGateway #javascript #nodejs
  • Навчання та стиль

КОМЕНТАРІ • 85

  • @BiteSizeAcademy
    @BiteSizeAcademy  2 роки тому

    ⚡️ NEW VIDEO: How to use versioning and aliases to deploy lambda functions? (/w API Gateway) ua-cam.com/video/OGMaE63YgEU/v-deo.html

  • @archidvignesh5368
    @archidvignesh5368 Рік тому +1

    What an amazing tutorial. You deserve more than a million subs. Please keep the videos coming

  • @khandoor7228
    @khandoor7228 3 роки тому +1

    Excellent please do more of these types of tutorials.

  • @DecypherMedia
    @DecypherMedia 2 роки тому +1

    this was an excellent tutorial, thank you.

  • @momulla5639
    @momulla5639 2 роки тому

    Genius video. Really enjoyed this one. Also very well explained, 10/10 for all of it . My own further request would be that it would be nice to see and edit message feature too :)

  • @jesusmuhammad8220
    @jesusmuhammad8220 2 роки тому

    so detailed and super helpful for a beginner, THANK YOU SIR

  • @user-yn8vs6uc5n
    @user-yn8vs6uc5n Рік тому

    So much useful for my project in 2023. Thankyou

  • @JJLabajo
    @JJLabajo 3 роки тому

    Awesome, I think you deserve thousands of subscribers. Keep up the work brother.

  • @sadev0
    @sadev0 3 роки тому +7

    Hey Alex, thanks for this tutorial.
    It would be great if you make a complete series on Serverless SASS application with AWS CDK and reactjs

  • @TuanTran-zc5ei
    @TuanTran-zc5ei Рік тому

    Thank you for this tutorial. This is a great guide to learn WebSocket API in AWS.

  • @seanknowles9985
    @seanknowles9985 3 роки тому +1

    Yo what amazing content !!!

  • @parkerschlank1713
    @parkerschlank1713 Рік тому

    Exceptional tutorial. Subbed. 🤩

  • @abdulbasitrana2743
    @abdulbasitrana2743 7 місяців тому

    Excellent tutorial and very well explained in detail.

  • @taufinews5736
    @taufinews5736 Рік тому

    Very good tutorial. Compact and rich in content.

  • @petrovandrey9735
    @petrovandrey9735 Рік тому

    This is amazing!!! Thanks for sharing with us ))

  • @kidsAdventuresvlogs
    @kidsAdventuresvlogs Рік тому

    It was great learning from this video about AWS API

  • @alexgolubev1182
    @alexgolubev1182 Рік тому

    sustained, informative, thank you

  • @stevenlin0719
    @stevenlin0719 2 роки тому

    Thank you so much! Very helpful.

  • @sourabhk2373
    @sourabhk2373 2 роки тому

    Very Very well explained.

  • @Cedielagekohaha
    @Cedielagekohaha 2 роки тому

    So helpful man!

  • @guillaume5623
    @guillaume5623 2 роки тому

    Such a great video, thank you very much 👍

  • @nahomberhe9640
    @nahomberhe9640 2 роки тому

    Amazing!! Thank you!

  • @tamer5639
    @tamer5639 3 роки тому +1

    Really good walkthrough. You're only 2 subscribers away from 1000, so I'm gonna have to subscribe! :D Almost there!

  • @abhisharma1471
    @abhisharma1471 7 місяців тому

    thankyou for this video it help me alot , if someone looking to understand the basics of aws websocket just watch this video
    thanks once again

  • @PaulPetersVids
    @PaulPetersVids 3 роки тому

    I've been looking for a good api gateway websocket gateway. Thank you!

  • @garyboss583
    @garyboss583 Рік тому

    Great video, super Like

  • @arshdeepkumar2586
    @arshdeepkumar2586 2 роки тому

    Excellent

  • @adkap990
    @adkap990 Рік тому

    Love you sir.. You are really great.. Thank You so Much...

  • @geekthegeek730
    @geekthegeek730 2 роки тому

    🤤more more tutorials!

  • @Duckzzzzzzzzzz
    @Duckzzzzzzzzzz 9 місяців тому

    I don't ever comment, but I just wanted to say that I appreciate the pace of your content.

    • @dhrubdas2975
      @dhrubdas2975 3 місяці тому

      dude i am getting an error Unexpected server response: 502
      what should i do
      how to solve

  • @likithravva2246
    @likithravva2246 8 місяців тому

    Awesome tutorial ALex!!Love from india

    • @sampatil5474
      @sampatil5474 4 місяці тому

      i have some problem with implementation can u help?

  • @user-tr6tp5qy7y
    @user-tr6tp5qy7y 2 роки тому

    thank you very much

  • @swethareddy8550
    @swethareddy8550 2 роки тому

    Thank you

  • @alibarznji2000
    @alibarznji2000 2 роки тому

    I like you "Bob" (:).
    subbed

  • @kunalghosh1117
    @kunalghosh1117 2 роки тому +5

    Solid tutorial...Could you please provide the complete set of working codes? It will be easier to run and check things on local.
    Thanks in advance!

    • @BiteSizeAcademy
      @BiteSizeAcademy  2 роки тому +2

      I've added a link to the github repo in the description

  • @edilsonfb
    @edilsonfb 2 роки тому

    Thank you for the video, it really helped me! I've facing an issue regarding using only serverless.yml to deploy the application. Locally everything works, but on aws the postToConnection only send if a user has joined. I'm saving the data in mongogb. Is there a huge difference by doing the firsts steps in the video and doing locally?

  • @tnmyk_
    @tnmyk_ 2 роки тому

    Great video! How can I make the web app hosted completely on cloud, without having to use the terminal/local host?

  • @sekhniashvili
    @sekhniashvili 2 роки тому +3

    Hey man,
    Nice and helpful video. Thank you.
    I get Forbidden error when sending message from socket client {"message": "Forbidden", "connectionId":"some_ID", "requestId":"some_ID"}
    I think I have not missed any step. The request does not appear in lambda logs, so I think API gateway blocks the request for some reason.

  • @okeyshourovroy2769
    @okeyshourovroy2769 2 роки тому

    Please make a secure video on demand like netflix using mern stack and aws.
    New subscriber 😊

  • @eruiluvatar6178
    @eruiluvatar6178 2 роки тому

    One question, what about pricing? Can we use this solution for a high load system?

  • @fedelecavaliere5249
    @fedelecavaliere5249 2 роки тому

    Very nice! But I was questioning if using Lambda what it's billed to me it's per say 100ms for each client for every message. On the other hand Lambda is taking up and storing my variables with my ids... How does Lambda bills me?
    Thank you!

  • @chengyiliu2277
    @chengyiliu2277 2 роки тому

    Hello, do you have a tutorial on how to write chat application on google function?

  • @AbhishekKumar-wx3dh
    @AbhishekKumar-wx3dh 5 місяців тому

    How do you handle error from the lambda fn. Error which can come from not connecting to db.

  • @jixster1566
    @jixster1566 2 роки тому

    Please make a video on how to do authentication for websockets

  • @user-ow4wj6sr9h
    @user-ow4wj6sr9h 11 місяців тому

    I have a question please , When a user creates a chat room and adds a members for this chatRoom ,How can we generate connectionId for each member to be able to receive connectionId

  • @evanserickson
    @evanserickson 2 роки тому

    No link to the React Components for the front end?

  • @shaheerahmed5234
    @shaheerahmed5234 2 роки тому

    what if bob is disconnected and jimmy wants to send message to bob how to handle this situation like in chat application . The problem is connection id is recreated when ever the user is join the chat .

  • @CATAPASMARENT
    @CATAPASMARENT 2 роки тому

    When i send a message i always go in the $default routeKey any advice or code sample ?

  • @smritieligar2518
    @smritieligar2518 Місяць тому

    i am getting Unexpected server response: 502 when i run wscat(9:38 timeline in the video). how do i solve it?

  • @user-yn8vs6uc5n
    @user-yn8vs6uc5n Рік тому

    Could you make a video on aws opensearch

  • @gideonwekesa_
    @gideonwekesa_ 2 роки тому +2

    Amazing! Kindly share the github repository of the frontend code.

    • @BiteSizeAcademy
      @BiteSizeAcademy  2 роки тому

      Thanks! Added the links to the repo in the description

  • @user-kw7fj2gc8z
    @user-kw7fj2gc8z 3 місяці тому

    Is there a way to see how much this will cost with aws price calculator?

  • @bhavanishankar5204
    @bhavanishankar5204 2 роки тому

    hi can u pls tell me how to make a chat application using dynamodb and nodejs without using lambda/serverless???? The user wil send u a text message ,u have to store it in dynamodb (you read it later and reply them or live reply)!! is it possible to do this in this way ?? if not please tell me!!! y

  • @isohumulone
    @isohumulone 6 місяців тому

    Where is the array variable "ids" initialized.

  • @shitalkhoje4946
    @shitalkhoje4946 Рік тому

    I really really need a urgent help if anyone can pls...
    Hey Alex...and other people reading this comment
    ...can anyone tell me how to open this CLI from lambda function whose prompt will be lambda too....
    I'm.not getting how in this video at 9.30 timing the cli opens from the lambda service window....
    Pls help urgent

  • @duongucthang2191
    @duongucthang2191 Рік тому

    could you teach me how to run the client

  • @user-wy6vm9nv3z
    @user-wy6vm9nv3z 4 місяці тому +1

    I am not getting response from web socket api Connected (press CTRL+C to quit)
    > {"action":"setName","name":"bob"}
    >

    • @KenyK47
      @KenyK47 3 місяці тому

      Did you find a solution to this?

  • @headmaster499
    @headmaster499 2 роки тому +1

    Do you mind sharing the repo for the lambda code? I cant seem to get a response back when I use Wscat to test.

  • @cenullum
    @cenullum 2 роки тому +1

    for now aws lambda doesnt support binary so you need to send as text. I was getting problem on my app because of it

  • @jshossen
    @jshossen 2 роки тому +2

    Great Videos. I implemented your way. but my connection returns 500 internal server errors.

    • @studiomonty
      @studiomonty Рік тому +2

      Did you find a solution to this? I'm having the 500 error as well

    • @emmy0021
      @emmy0021 Рік тому +1

      @@studiomonty same

  • @anhadparashar710
    @anhadparashar710 2 роки тому

    hey, does it work?

  • @oldyoung
    @oldyoung 2 роки тому +1

    The message store in dynamodb ?

    • @amra1610
      @amra1610 2 роки тому

      same question?

  • @kazinayem2011
    @kazinayem2011 2 роки тому

    What about ChatClient component? You didn't show us what's inside it. Could you please share that code?

    • @BiteSizeAcademy
      @BiteSizeAcademy  2 роки тому +1

      Added to the video's description

    • @kazinayem2011
      @kazinayem2011 2 роки тому +1

      @@BiteSizeAcademy I appreciate your quick reply and this is really my luck to have the source code. Started practicing your tutorial. Many many thanks.

  • @mcdoggy520
    @mcdoggy520 2 роки тому +2

    I’m getting an unexpected serverr response: 502 :

    • @peppyday
      @peppyday 2 роки тому

      any solution

    • @BiteSizeAcademy
      @BiteSizeAcademy  2 роки тому +1

      Try to check the logs of the lambda function to see what causes the error,
      then troubleshoot it: aws.amazon.com/premiumsupport/knowledge-center/lambda-troubleshoot-invoke-error-502-500/

    • @peppyday
      @peppyday 2 роки тому +1

      @@BiteSizeAcademy worked

    • @peppyday
      @peppyday 2 роки тому

      any idea how to store the chat message in dynamodb ( need schema )

  • @Siscerto
    @Siscerto Рік тому

    why should we use .promise() when we are using async and await

  • @Jagadish47
    @Jagadish47 Рік тому

    HOW lambda holds the names object ( var names = { }; ) for every request won't it become resetted ???

  • @DuffMan
    @DuffMan 5 місяців тому +1

    If anyone is trying this lately, I don't know if something changed in AWS, but I was getting bad gateway from the wscat connection. So I checked cloudwatch and it was giving me this error:
    Error: Cannot find module 'aws-sdk'".
    So I installed @aws-sdk/client-apigatewaymanagementapi directly and it fixed the issue.
    Usage:
    import {
    ApiGatewayManagementApiClient,
    PostToConnectionCommand,
    } from '@aws-sdk/client-apigatewaymanagementapi'
    const command = new PostToConnectionCommand({
    ConnectionId: id,
    Data: Buffer.from(JSON.stringify(body)),
    })
    return await client.send(command)

    • @Neosdragon
      @Neosdragon Місяць тому

      Can you further elaborate on this?