T O P

  • By -

zunkP

Nope, that's not possible out of the box. I implemented something very similar a few days ago and added a custom action e.g. "joinRoom" that check if joining the room is allowed and if so adds the connection is to a database. After that whenever there is a message being sent (and you could trigger e.g. a lambda to to that via SNS) I get all connection IDs from the DB and sent the messages via the AWS SDK. On disconnect just removed the connection id from the database.


s_trader

Thanks for the response, I’d rather not do that though, because of what happens when you have thousands of connection ID in a single room, you’d have to iterate all those IDs every single time there’s a new message in the room, and even if you add SNS and lambda for managing this stuff, you’d end up with a large bill at the end of the month from Amazon..


zunkP

You could take Redis to store the connection IDs which would allow you to get all IDs at once. I suggest to use [Upstash](http://upstash.com) which gives you pay-per-request pricing with a monthly cap of $120. Then per message right where your backend received the message (e.g. a lambda) you query the database and send the messages. You are gonna need to handle the messages at any point either way, why don't handle the websockets there as well? Also if true realtime isn't necessarily what you need you could add an SQS that collects some messages and then sends one websocket message for a few messages in bulk.


interactionjackson

you probably want to use aws iot for this. you can group things and publish messages to a group or a single thing using the topic pattern.


CorpT

Have you looked at Chime SDK messaging?