0
votes

I am using Akka-HTTP to return a response in form of String [30 - 40 MB].

When I deploy my Akka-HTTP server and make a request to fetch the data from some URI then every time it gets stuck after several MB's and stop fetching the complete response.

Is there any way that I return my whole large response without getting stuck in between.

HttpResponse(StatusCodes.OK, entity = myLargeResponseAsString)

Thanks

1
Does the "large response" come as a huge string from somewhere outside of your control or are you collecting/concatenating it yourself? Asking since one of the benefits of Akka HTTP is to not have to do that but instead stream data as it arrives. - johanandren
I am getting this huge response directly from Apache Solr. Solr is returning this large response in the form of a string. - Akash Sethi

1 Answers

1
votes

Maybe this could help:

path("yourpath") {
      get {
        complete {
          val str2 = scala.io.Source.fromFile("/tmp/t.log", "UTF8").mkString
          val str = Source.single(ByteString(str2))
          HttpResponse(entity = HttpEntity.Chunked.fromData(ContentTypes.`text/plain(UTF-8)`, str))
        }
      }