I'm using Amazon Elastic Beanstalk to run a nodejs web page. I just want to send notifications to this webpage from AWS SNS and catch them in real time. So, when i publish to the HTTP endpoint, nothing happens and i don't know how to get the notification.
As Http endpoint, i set my AWS Elastic-Beanstalk http address.
I'm reading the Amazon docs but nowhere i can find how to catch the sns message once at the http endpoint.
Please, any help will be very appreciated . Thanks.
The moment you give your HTTP/HTTPS endpoint and create subscription from aws console, what happens is , the Amazon sends a subscription msg to that endpoint. Now this is a rest call, and your app must have a handler for this endpoint, otherwise you miss catching this subscription message. The httpRequest object that your handler is passed, needs to access it's SNSMsgTypeHdr header field. This value will be "SubscriptionConfirmation". You need to catch this particular message first and then get the subscription url. You can handle it in your app itself or maybe print it out, and then manually visit that url to make the subscription. I would ideally suggest to make a subscription to the same topic at the same with your mail id, so that everytime your app gets a messages pushed , your mail id also gets the message(albeit the tokens will be different) but at least you will be sure that the message was pushed to your endpoint. All you need to do is keep working your app to handle the messages at that endpoint as per your requirements then.
After you subscribe your endpoint, Amazon SNS will send a subscription confirmation message to the endpoint. You should have code at the endpoint that retrieves the SubscribeURL value from the subscription confirmation message and either visit the location specified by SubscribeURL itself or make it available to you so that you can manually visit the SubscribeURL, for example, using a web browser.
Amazon SNS will not send messages to the endpoint until the subscription has been confirmed.
You can use the Amazon SNS console to verify that the subscription is confirmed: The Subscription ID will display the ARN for the subscription instead of the PendingConfirmation value that you saw when you first added the subscription.
There are 3 types of messages with SNS. Subscribe, Unsubscribe, and Notification. You will not get any Notification messages until you have correctly handled the subscribe message. Which involves making an API request to AWS when you receive the Subscribe request.
The call in this case is ConfirmSubscription: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SNS.html#confirmSubscription-property
Once you do that, then you will start receiving notification messages and you can handle those as your code allows.