user3294786
user3294786

Reputation: 177

Akka Http Connection Refused Error

I have a web-service written in Akka where for each user I am making a post request(to encrypt some data) as follows:

http.singleRequest(HttpRequest(method = HttpMethods.POST, uri = encryptUrl, entity = request))

However after a few hits I am getting a ConnectionRefusedError to the encryption server. It seems to be working intermittently. I looked up some potential issues but still nothing.

Finally I found one issue where not closing a connection could cause this scenario. Does it sound right ? Also how can I close a connection in the above case in Akka HTTP.

Upvotes: 0

Views: 970

Answers (1)

This may be caused by not fully consuming the request/response entity. From the documentation:

Warning

Consuming (or discarding) the Entity of a request is mandatory! If accidentally left neither consumed or discarded Akka HTTP will assume the incoming data should remain back-pressured, and will stall the incoming data via TCP back-pressure mechanisms. A client should consume the Entity regardless of the status of the HttpResponse.

Upvotes: 1

Related Questions