AWS WebSocket API (Real-time chat application using python)

2024 ж. 23 Мам.
13 346 Рет қаралды

In this session we will discuss about creating a real time chat application using AWS API gateway.
github.com/listentolearn/aws-...

Пікірлер
  • Amazing tutorial! This is very underrated channel. Your content is really good. I never thought that it will be possible to implement end to end websocket chat application under 15 minutes, I always thought that it will be complicated. But you made it really simple. :)

    @bhushangosavi435@bhushangosavi4355 ай бұрын
    • thanks! you made my day :)

      @listentolearn2363@listentolearn23635 ай бұрын
  • Hi, it is very strange you have so few subscribers... You make very high quality videos and use very good examples. It is real helpful to watch your videos. Thanks a lot! I wish you good luck!

    @alexmatveev7246@alexmatveev7246 Жыл бұрын
    • Thanks for your encouraging words.. this made my day :)

      @listentolearn2363@listentolearn2363 Жыл бұрын
    • @@listentolearn2363 thank you:) just finished with websockets chat example

      @alexmatveev7246@alexmatveev7246 Жыл бұрын
    • @@alexmatveev7246 emra adivasi

      @nitheshrao8499@nitheshrao8499 Жыл бұрын
  • This really helped me out! Great quality, keep going :)

    @tobiasp2664@tobiasp2664Ай бұрын
    • Thank you :)

      @listentolearn2363@listentolearn2363Ай бұрын
  • Love the video! It is of very high quality

    @joejiang8353@joejiang8353 Жыл бұрын
    • Thanks, Joe :)

      @listentolearn2363@listentolearn2363 Жыл бұрын
  • Super very nice 👌👌👌👍🏽😊

    @saradhapurushothaman1755@saradhapurushothaman1755 Жыл бұрын
    • Thanks a lot :)

      @listentolearn2363@listentolearn2363 Жыл бұрын
  • Great Video thank you!!

    @genewachtel5900@genewachtel59005 ай бұрын
    • Thanks :) Glad you found it useful.

      @listentolearn2363@listentolearn23635 ай бұрын
  • Hi,! great video. Do you know the easiest way to handle abrupt disconnections? Because when this happends i get an empty event in disconnect lambda function (so i can't delete the connectionid from the dynamodb). And btw, do you know if there is a way of brodcast a msg to all the connected clients without having to manually store the connectedId's? Thanks!!

    @lucasmancini1283@lucasmancini1283 Жыл бұрын
    • About the empty events, i get those when i connect and disconnect with postman without sending any messages.

      @lucasmancini1283@lucasmancini1283 Жыл бұрын
    • Hi Lucas, thank you. AWS documentation mentions that $disconnect is a best-effort event. So, it cannot guarantee delivery. Setting up a TTL on the dynamodb table might help in cleaning up the data. Unfortunately, we need the connectionId to send the messages and there is no other way to get the ids (as far as I know) without persisting them ourselves somewhere. You could try storing them in elastisearch or any other storage of your choice, if dynamodb doesn't seem reasonable for your usecase.

      @listentolearn2363@listentolearn2363 Жыл бұрын
  • Nice tutorial! What did use to design the diagrams?

    @davioliveira5153@davioliveira5153 Жыл бұрын
    • thanks :) ppt.

      @listentolearn2363@listentolearn2363 Жыл бұрын
  • Nice tutorial !! Very informative .. Can you please confirm that can we do this in free tier account ??? Or is there any charges if we create this environment ??

    @rushikeshdhajal8762@rushikeshdhajal8762 Жыл бұрын
    • Thank you! glad you found it useful. yes, this is free for free tier account. However, there are restrictions on the number of messages and connection minutes per month, see below 1M REST API CALLS RECEIVED | 1M HTTP API CALLS RECEIVED | 1M MESSAGES | 750,000 CONNECTION MINUTES per month please see here for more details - aws.amazon.com/api-gateway/pricing/

      @listentolearn2363@listentolearn2363 Жыл бұрын
    • It's free for SC ST caste.

      @nitheshrao8499@nitheshrao8499 Жыл бұрын
  • nice video, what tool do you use to test your url 'workspace'

    @unconnu8481@unconnu8481 Жыл бұрын
    • Thank you :) the tool used to test in this video is postman www.postman.com/downloads/

      @listentolearn2363@listentolearn2363 Жыл бұрын
  • if i had to only make this peer to peer chat, rather than a brodcast chat, will this similar outlined process via websockets lambda be an ideal practice to go through, if yes, what changes should be made in the vedio, or if you can create one such vedio about same about peer to peerchat, that would be so good.

    @_amitmalik@_amitmalik9 ай бұрын
    • p2p could be implementing by tracking down a certain user's connection ID or user ID and only pushing the message to them (rather than pushing the message to all of them).

      @ejmurc@ejmurc8 ай бұрын
    • Hi Amitism, Thanks for your interest. One way to implement this is by making below changes to the setup: 1. Add an additional attribute to dynamodb which stores a user specific unique attribute (like userId) against each connection. 2. Include the userId to whom the message has to be sent to as one of the attributes to the message while sending the message 3. Query the dynamodb (instead of scanning) to get the specific connectionId against the userId 4. Send the message just to that one connection (instead of a for loop)

      @listentolearn2363@listentolearn23638 ай бұрын
  • If the Websocket is public facing how do you deal with authorisation of users? As I am aware you cannot use custom headers in websockets to securely transfer the JWT.

    @Matt-kc9xr@Matt-kc9xr6 ай бұрын
    • Hello, you could make use of lambda authorisers to control who can invoke your apis. you will be able to access the headers.

      @listentolearn2363@listentolearn23636 ай бұрын
    • @@listentolearn2363 If a client is making a http upgrade request, you will not be able to access typical authentication headers, as most browser WebSocket clients do not allow for custom headers. If you want to pass a JWT, you will need to pass it as a query param in the URL.

      @maxsadler7231@maxsadler72315 ай бұрын
  • Great video it's really helpful!! But what if I wish for messages from terminal 1 only to be sent to terminal 2 and from terminal 3 only to be sent to terminal 4 like private chats on an app.

    @KarimFayed-oy5oo@KarimFayed-oy5oo3 ай бұрын
    • Hi, Thank you :) One way to implement this is by making below changes to the setup: 1. Add an additional attribute to dynamodb which stores a user specific unique attribute (like userId) against each connection. 2. Include the userId to whom the message has to be sent to as one of the attributes to the message while sending the message 3. Query the dynamodb (instead of scanning) to get the specific connectionId against the userId 4. Send the message just to that one connection (instead of a for loop)

      @listentolearn2363@listentolearn23633 ай бұрын
    • @@listentolearn2363 Thanks a lot. Really appreciate it ❤

      @KarimFayed-oy5oo@KarimFayed-oy5oo2 ай бұрын
  • This was a nice tutorial, Can I know how to implement this API to a python code and make a chat application and if possible can you tell me what is to be learned for it?

    @SivaKumar-oq8em@SivaKumar-oq8em Жыл бұрын
    • Thanks for your support. Here is the python code reference - github.com/listentolearn/aws-websocket-api

      @listentolearn2363@listentolearn2363 Жыл бұрын
  • thanks-

    @prabhudevbm2921@prabhudevbm29215 ай бұрын
    • Welcome :)

      @listentolearn2363@listentolearn23635 ай бұрын
  • Thank you for this. Is this free or is there a charge? If there is a charge, how much is it?

    @suave9623@suave9623 Жыл бұрын
    • Hi Suave, Thanks for your support. You are charged for what you use and the cost depends on number of requests per month and the total number of connected minutes. Also, the price varies based on the aws region where the websocket api is setup. Exact costs can be found here - aws.amazon.com/api-gateway/pricing/

      @listentolearn2363@listentolearn2363 Жыл бұрын
  • I have one doubt. Can we host multiple kafka producers in one ec2 instance?

    @nainaarabha9186@nainaarabha918610 ай бұрын
    • Hi nainaarabha, apologies, I dont have much experience with kafka. however, this aws documents seems to be a good source - aws.amazon.com/blogs/big-data/best-practices-for-running-apache-kafka-on-aws/ and as per this, aws recommends one producer per instance per az.

      @listentolearn2363@listentolearn236310 ай бұрын
  • It shows me the error 502 bad gateway when i try to connect to the api. Do you know why this can happen? Edit: i think It will run if i change the return of the lambda fuctions

    @gabrielgarciamartinez5256@gabrielgarciamartinez5256 Жыл бұрын
    • Hi Gabriel, Could you please check the cloudwatch logs and let me know what you see there? If you don't see any errors there, then please enable the logging at api gateway level and check the logs there to know more about the error.

      @listentolearn2363@listentolearn2363 Жыл бұрын
    • ​@@listentolearn2363 Hi! I have checked the cloudwatch to see the errors. I have connected your implementation with iot core and with a website made with the S3 module. It works perfectly, thanks a lot.

      @gabrielgarciamartinez5256@gabrielgarciamartinez5256 Жыл бұрын
    • @@listentolearn2363 what type error are in cloudwatch logs?

      @suryaprakashsharma2165@suryaprakashsharma21654 ай бұрын
  • Hello Dear Mam, I have got this error, please tell me how to resolve this problem [ERROR] TypeError: '_Environ' object is not callable Traceback (most recent call last): File "/var/task/lambda_function.py", line 11, in lambda_handler TableName = os.environ('WEBSOCKET_TABLE'),

    @suryaprakashsharma2165@suryaprakashsharma21654 ай бұрын
    • try this pls - TableName=os.environ['WEBSOCKET_TABLE']

      @listentolearn2363@listentolearn23634 ай бұрын
  • Hello mam, I have solved this problem but there is one occurred again which is {"message": "Internal server error", "connectionId":"R1CnEcJtoAMCKIQ=", "requestId":"R1C_kEvEoAMF5qg="} while sending the message

    @suryaprakashsharma2165@suryaprakashsharma21654 ай бұрын
    • Could you please check the cloudwatch logs to get more details about the error?

      @listentolearn2363@listentolearn23634 ай бұрын
    • HI did you manage it?

      @khoatruongang2001@khoatruongang20013 ай бұрын
  • Can you help me with low level and heigh level demo on AWS API gateway

    @chakravathyvas1163@chakravathyvas116311 ай бұрын
    • sure, here are few links for API gateway related content - AWS API Gateway | REST API for CRUD operations - kzhead.info/sun/oLWoppWdnKaJmJs/bejne.html AWS API Gateway | Lambda and Cognito Authorizers - kzhead.info/sun/hJmLp9ygeoGErHA/bejne.html

      @listentolearn2363@listentolearn236311 ай бұрын
    • I have tried with same lambda code for websocet It's getting error 500 in postman tool Can u help me with code

      @chakravathyvas1163@chakravathyvas116311 ай бұрын
    • Please check cloudwatch logs to get more details about the error.

      @listentolearn2363@listentolearn236311 ай бұрын
  • I need to send to different chatRooms , How this can be done

    @user-ow4wj6sr9h@user-ow4wj6sr9h9 ай бұрын
    • This chat application will work for multiple chat rooms. It uses the id stored in dynamodb against each connection to send out the messages.

      @listentolearn2363@listentolearn23639 ай бұрын
  • how to add 5GB of In-Memory Cache in websocket API?

    @madiwalappalagali2752@madiwalappalagali2752 Жыл бұрын
    • Hi Madiwalappa, There does't seem to be any caching options available at websocket api gateway level. If you are using lambda as the integration for your routes, you could add caching within lambda. There are several options for that like lambda extension. However, if you are using rest api then there are caching options available at the api gateway level. Thanks.

      @listentolearn2363@listentolearn2363 Жыл бұрын
  • Please make one lambda function to send message to one person only

    @gigachad6844@gigachad6844 Жыл бұрын
    • Hi GigaChad, Thanks for your interest. One way to implement this is by making below changes to the setup: 1. Add an additional attribute to dynamodb which stores a user specific unique attribute (like userId) against each connection. 2. Include the userId to whom the message has to be sent to as one of the attributes to the message while sending the message 3. Query the dynamodb (instead of scanning) to get the specific connectionId against the userId 4. Send the message just to that one connection (instead of a for loop)

      @listentolearn2363@listentolearn2363 Жыл бұрын
  • Mam, i have an offer for you . can you please help me to configure my web app . I'll pay you for that.

    @ashishwaykar2838@ashishwaykar2838 Жыл бұрын
    • Thanks for your offer. However, I am focusing only on making video content at this time..

      @listentolearn2363@listentolearn2363 Жыл бұрын
    • what ammount you should take expect to i pay the other guy for that work ? for configure my server please help me to take decision ! my budget is $20-$30

      @ashishwaykar2838@ashishwaykar2838 Жыл бұрын
    • @@listentolearn2363 & my work is too small like i just need an SSL with websockets

      @ashishwaykar2838@ashishwaykar2838 Жыл бұрын
    • @@ashishwaykar2838 bro i had to sell my house and my mother's bangles for that project.Please don't fall for such traps.

      @nitheshrao8499@nitheshrao8499 Жыл бұрын
KZhead