使用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.