Reputation: 72755
I'm using a service that runs outside of my premises that uses a websocket API to emit events that occur inside it. Let's call this wss://X
.
I have a web app that currently runs a websocket client that connects to wss://X
and if it receives an event fires a call back that does some book keeping (update a database, queue a notification).
I'd like to keep this separate from my web app (different developer, separate logic etc.). I'd like to have something I'm called a listener
for wss://X
which will just sleep till something comes up on this connection and if so, do something and then shut down.
This seems like a good candidate for AWS lambda. Short running functions that do book keeping based on events but I'm not sure how I can trigger them. Someone suggested AWS API gateway but I don't know how to make it listen (rather than bind) to a certain URL and then trigger lambda functions based on events that it receives. If this is not possible, what can I use on AWS that would solve this problem for me?
Upvotes: 1
Views: 1444
Reputation: 666
You can't use Lambda for long-running tasks (refer to Is it possible to subscribe to a WebSocket in a serverless fashion using AWS?).
Considering that the listener needs to be long-running as it must listen to events from wss://X
, an alternative that I can think of is to start an EC2 instance that runs code which continuously listens to wss://X and does the operations that you want.
Upvotes: 2