**I have created realtime activities website.
currently my website is like this:
frontend page created websocket with endpoint url wss://xyz.com/chat/$scope.userId
In my backend i store a map table of userId-Websocketconnection
when anyone likes image of userId-5 , backend sends notification to websocketConnection whose userId is 5
But now i want to use Aws websocket api
i am confused at several points
how to send userId with websocket connection request to aws websocket api
using aws websocket api ,how can i store this connectionid and user id in my springboot database
when someone likes image of userId-5 , how will i send notification to websocket connection of userId-5
Is it possible using aws websocket api. Please help me
**
That's what exactly APIGateway websocket protocol offers.
You need to connect to websocket, then send a message (json) which has userid in it. Example message below.
{"action": "SUBSCRIBE","payload": {"userId":"123"}}
On APIGateway you can create SUBSCIRBE route and map it to backend endpoint as Integration request where you store connection id into database.
https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-integration-requests.html
Whenever your spring boot application wants to push notifications, you can make use of AmazonApiGatewayManagementApi and broadcast the message.
https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-how-to-call-websocket-api-connections.html
Related
I have build a API gateway stack that allows clients to connect and push data into a kinesis data stream.
I have a custom authentication lambda that runs on the initial connection which correctly validates the user. The session information is then written into dynamoDB along with some other process data that I would like to return to the client before it the client starts to send data to websocket $default route.
I've added a lambda to the $connect route and tried in both the authorization and connect lambda functions to return data via headers, directly, and through the apigateway #connections method but none of these method work, and the connection isn't yet established to be able to send data back down to the client.
Is this possible? Or would the only way to achieve this be to delay the response through an SQS queue, or to have the client request the data in someway before it starts?
My intention is to build a chatbot thru aws lex and optionally communicate with agent in aws connect.
For this I have created a custom chatbot widget which connects to api gateway and forwards message to lex thru websocket and respond back to chatbot widget. I also redirect these message to agent rather than lex in cases where customer whats to chat with agent.
Im able to send message from lamda to agent, but I am having trouble receiving message back from agent. How can solve this ?
This is a system design question about creating a messaging application (like WhatsApp or FB messenger).
I saw a video that had the users connected via websocket to the API Gateway , then API GW pushed the message onto SQS - which was then polled by the EC2 compute layer to process the message (store it in the db) and hopefully send the message back to recipient.
How can the backend ec2 / compute layer send the message to the recipient (Bob) ? Can it just call a route on the API Gateway and it would know the connection details of the recipient and where to send? Would there need to be an additional caching layer to store info about the connection details of every user? I'm newer to AWS so not sure how this is accomplished and whether you can call API GW to send back to a user.
Also if you know how group chat would work please share.
As mentioned in the documentation, your backend EC2 servers can send messages to the connected clients directly via the #connections API. This documentation page walks you through how to do that.
For this, you'll need to add the connectionId to the header. See this answer on how to do so.
I have been working on developing a chat-bot for an application. I want to use Amazon Connect to power chat-bot. I wanted to understand, if there is a way through which Amazon Connect fetches response from my backend service whenever client posts a question in chatbox.
Expected flow
client (asks question) ---> AWS Connect (calls service) ---> My backend Service (sends response for the question)
Thanks
You can integrate the contact flow with a lambda function, then use the lambda function to call your own backend service.
I'd really appreciate any advice on the following. Building a real-time infrastructure for android mobile devices to connect to windows POS systems.
POS system will run a .NET app that will connect to AWS WebSocket API Gateway and register with a storeId.
Android device will call an AWS HTTP API Gateway endpoint to retrieve POS information from the store.
Here's the part I'm not sure about. I'd like the AWS HTTP endpoint to trigger a lambda function that will lookup the websocket connectionId from the storeId and send a message to the connected store and wait for a new message from the store. The store client would receive the websocket message, collect the info, then send it to dynamodb and then notify the original lambda function that the data is ready to send back.
Can lambda do that? Connect to another websocket api, wait for a message, then disconnect, and eventually return the original HTTP API request to the android client? Am I going down the wrong path?
Is there a better way for an AWS HTTP API endpoint to send a message to a websocket client and get a response?
My other approach was to have the android client connect via websocket as well. Send request messages back and forth via websocket, and then call http api to upload / download larger data payloads. But would still like to find some way to provide HTTP API to others in order to retrieve the store data via the websocket client.