Is there a solution for the issue with multiple http calls returning "connection closed by server"?

178 views Asked by At

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

0

There are 0 answers