-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty Body Sent to HTTP Subscribers #45
Comments
I was able to work around this by setting the content-type of the request on the receiving end, which is missing from the SNS publish.
HTH. |
in my case I just used because it was sending a json content with a content type "plain/text". i also had to parse the json by myself |
Was banging my head on my keyboard for a while on this. Posting for anyone using Express v4+: app.use(
express.json({
type: [
'application/json',
'text/plain', // AWS sends this content-type for its messages/notifications
],
})
) |
The content type is
|
This worked for me, thanks |
Solution from @damionvega still applies in January 2022! - However, I didn't want to always parse every "text/plain" request as JSON. Instead I wanted this workaround to only happen for Amazon Services (like SES or SNS). I figured that I could simply use the "user-agent" to identify these requests: router.use(function(req, res, nxt) {
const json_parser_options = {
type: ["json", "*+json", "*/json", "application/json"],
strict: true,
limit: "5mb"
}
if(/Amazon/i.test(req.header("user-agent"))) {
json_parser_options.type.push("text/*")
}
express.json(json_parser_options)(req, res, nxt)
}) |
Sending messages to
http
subscribers do not work. APOST
request is made to the endpoint, but no data is sent in the body. However, thecontent-length
header is set the expected value as if a message was sent. I got the same result for two different http servers:netcat
andserver.js
(nodejs express wrapper). Additionally, I confirmed messages sent to the same topic but different types of subscribers (i.e. file protocol) does work as expected.command sent
aws sns --endpoint-url http://localhost:9911 publish --topic-arn arn:aws:sns:us-east-1:1465414804035:test-topic --message "test"
verbose logging of received msg from sns
POST /message HTTP/1.1 MessageExchangeId: 9a874dc5-3dc5-477f-90d2-4c4dd6e77c35 x-amz-sns-message-id: 9a874dc5-3dc5-477f-90d2-4c4dd6e77c35 x-amz-sns-message-type: Notification x-amz-sns-subscription-arn: 6df4ed2b-a650-4f7c-910a-1a89c7cae5a6 x-amz-sns-topic-arn: arn:aws:sns:us-east-1:1465414804035:test-topic User-Agent: Jakarta Commons-HttpClient/3.1 Host: subscriber:8010 Content-Length: 91 # no body data?
environment setup
./docker-compose.yml
./sns/db.json
The text was updated successfully, but these errors were encountered: