question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Empty Body Sent to HTTP Subscribers

See original GitHub issue

Sending messages to http subscribers do not work. A POST request is made to the endpoint, but no data is sent in the body. However, the content-length header is set the expected value as if a message was sent. I got the same result for two different http servers: netcat and server.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

version: "3.4"
services:
  sns:
    image: s12v/sns
    environment:
    - SUBSCRIBER_HTTP=subscriber:8010
    ports:
    - 9911:9911
    volumes:
    - ./sns:/etc/sns
  subscriber:
    image: subfuzion/netcat
    ports:
    - 8010:8010
    command: "-vl 8010"

./sns/db.json

{
    "version": 1,
    "timestamp": 1465414804110,
    "subscriptions": [
        {
            "arn": "6df4ed2b-a650-4f7c-910a-1a89c7cae5a6",
            "topicArn": "arn:aws:sns:us-east-1:1465414804035:test-topic",
            "endpoint": "http:{{env:SUBSCRIBER_HTTP}}/message",
            "owner": "",
            "protocol": "http"
        }
    ],
    "topics": [
        {
            "arn": "arn:aws:sns:us-east-1:1465414804035:test-topic",
            "name": "tms-session-api-events"
        }
    ]
}

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:6

github_iconTop GitHub Comments

27reactions
damionvegacommented, Jan 20, 2020

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
    ],
  })
)
13reactions
victorsferreiracommented, Apr 26, 2019

in my case I just used bodyParser.text()

because it was sending a json content with a content type “plain/text”. i also had to parse the json by myself

Read more comments on GitHub >

github_iconTop Results From Across the Web

req.body is empty one a post request sent from angular http post
I making a post request from my angular application to a node server. I'm using FormData and HttpClient to send the post.
Read more >
Fanout to HTTP/S endpoints - AWS Documentation
When you subscribe an endpoint to a topic, you can publish a notification to the topic and Amazon SNS sends an HTTP POST...
Read more >
Why my request.body is empty while request.params in not?
Hi guys,. I have this simple express code which prints the request.body. But it's empty. When I print request.query then I get some...
Read more >
Post requests from Cloud Function have empty body and the ...
get_json() instead of data=request.form . Introduction. In the last post I talked about creating a PubSub subscription using a cloud function with an...
Read more >
HttpResponse.BodySubscribers (Java SE 12 & JDK 12 )
java.net.http.HttpResponse.BodySubscribers ... Returns a body subscriber that forwards all response body to the given Flow.Subscriber , line by line.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found