1

I am attempting to hit the Amazon api with api calls for a bunch of services across all the regions. Approx 200+ API calls.

Using em-http-request to make the calls some complete while some fail with the error "connection closed by server" I have come across the closest resembling issue to this

EventMachine.run {
  150.times {
    http = EventMachine::HttpRequest.
             new("https://jsonplaceholder.typicode.com/posts", :keepalive => false).get

    http.errback  { p "failed #{http.error}" }
    http.callback { p "success" }
  }
}

PS: Interestingly the same code works like a charm on an EC2 instance, but fails with this error "connection closed by server" only on my dev machine. Seems like some sort of network issue

Casper
  • 33,403
  • 4
  • 84
  • 79
david
  • 88
  • 6
  • 1
    Can't you just rescue the failed attempts and retry? Also, you are sure this is not some throttling issue on Amazon? – Casper Mar 01 '17 at 09:13
  • no its not a throttling issue . have confirmed it by hitting a dummy api those many times but the issue persists..seems like an issue with event machine – david Mar 01 '17 at 09:37
  • perhaps amazon thinks its ddos attack? maybe their servers have some limitations for quantity of queries per minute or something like this. Try to use timeouts between your queries or proxy server. – sig Mar 01 '17 at 10:07
  • confirmed its not amazon...it happens with any request. I have even tried hitting https://jsonplaceholder.typicode.com – david Mar 01 '17 at 10:33
  • Can you create a minimally working code sample that reproduces the issue? – Casper Mar 01 '17 at 12:51
  • have updated the question description with a sample code along with some new findings – david Mar 01 '17 at 13:56
  • Tried it on my machine also. No problems. – Casper Mar 01 '17 at 16:08

0 Answers0