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. :)
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!
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!!
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.
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.
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)
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.
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).
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)
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.
@@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.
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?
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.
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
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 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.
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 ??
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/
sure, here are few links for API gateway related content - AWS API Gateway | REST API for CRUD operations - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-mQov1eetSec.html AWS API Gateway | Lambda and Cognito Authorizers - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Q5RwxhCONy8.html
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/
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.
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'),
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
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)
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