使用Amazon API Gateway支持的WebSocket API構建實時應用程序



要了解更多信息,請訪問:https://aws.amazon.com/api-gateway/

從簡單的網站和移動應用到物聯網應用,API已經改變了開發人員構建應用的方式。如今,許多開發人員正在遠離傳統的單片應用程序體系結構,而是創建較小的微服務,每個微服務都具有自己的API。在本技術講座中,我們將引導您通過Amazon API Gateway構建無伺服器API。我們將看一下API網關最近宣布的對WebSocket API的支持,以及如何使用它們來構建實時通信應用程序,例如聊天服務和流儀錶板。演講之後,您將具有為在基於伺服器,基於容器的應用程序和無伺服器應用程序上運行的後端構建REST和WebSocket API所需的基礎知識。

學習目標:
-概述Amazon API Gateway
-了解API Gateway中新的WebSocket API
-深入研究使用API​​ Gateway中的WebSocket API構建實時的無伺服器通信應用程序。

24 comments
  1. while building a web socket Api, it doesn't give any options to choose between edge-optimized, regional or private. Its a pain in the ass to implement security in AWS API gateway for web sockets. There is no resource policy to edit either. This tutorial is useless.

  2. I just went through this tutorial this weekend for our Twitch Hackathon here in Taipei. For the most part it was understandable with my past experience working with lambda with api gateway on rest api. The thing that got me stuck for a while was the signing signature portion. Eventually I managed to get it to work by mucking through the provided example in the docks but it was an example on how to sign python for dynamodb usage purposes. I had to go through the error messages and match the expected payload with the provided to finally get it to work. I think with examples like these, it would be great to provide the codes as a reference or to actually run through and code it with the audience for a more clear tutorial. Doing thorough overviews like this are useful for experienced AWS engineers but trying to onboard new developers it becomes a steep learning curve. Knowing what to do, it's not that hard of a pipeline, but without adequate clear instructions it turns people away from your great service.

  3. You gave zero explanation about how to setup the "myWSMessageFn" lambda function. You gave zero explanation about the security role involving the integration API Gateway / Lambda, which is a pain in the ass. You gave zero explanation about the $connect and $disconnect routes in the API gateway. This is nowhere near a deep diving, it barely scratches the surface.

    AWS is too complex and seriously lacking good documentation, and any tutorial you find is just mimicking the scarce official documentation.

  4. for some reason, no matter what i do, I'm always getting a 502 response from the $connect. I use the standard Lambda response JSON for integration with API Gateway. I'm lost

  5. First of all, Thank you for this tutorial. I now no longer have to deal with managing ec2 servers. Ok…so….I noticed that part where you send data to the websocket client via the socket's connection url is not included. Is there a FULL example of V4 signing for this tutorial. I understand how the pieces are derived from the lambda functions event.requestContext. Is there an example of the signing of the url string I built using those variables. (nevermind I see you use a python script called call.py)

  6. Is it possible to subscribe to a WebSocket in a serverless fashion using AWS?

    I am asking because in one of the scenarios I have to extract data from another web-socket endpoint (not managed by me) and I can either configure a lambda to wake up every x minutes and listens for the stream but that does not seem like the right way to do it. Please suggest what will be the valid architecture in this case?

  7. This is great! but struggled to get it to work "Internal server error" when following along myself – same with the blog entry. I get the impression that there are a few missing steps – for example, your $connect and $disconnect routes have been defined by the end of the video but you don't cover how. Could you please release his mini project in AWS SAM format?

  8. I have a question, why I can't invoke $connect route using {"action":"$connect","data":"Hello"} ?
    I am able to establish connection using wscat -c <WebSocket Url>, and I can invoke all custom route but when I try to invoke $connect route it gives me error {"message": "Forbidden", "connectionId":"TOxxxxA=", "requestId":"TOMxxxyQ=「}.
    Is it like $connect route is only used to establish a connection ?

  9. Really cool feature ! Greet presentation, however blue terminal background with green and blue letters makes my eyes bleed :,( ps. I am Watching video on mobile, so I guess for me effect is exaggerated

  10. I'm so excited about this. My desired app model wasn't even possible and I'd been wracking my brain to come up with alternatives that retained most of the benefits of serverless. I know I could've gone multi-cloud, but I'm just one developer and I don't have time to learn everything everywhere.

Comments are closed.