Using the spray 1.3.2 with Akka 2.3.6. (Acca is used only for spray).
I need to read huge files and make an http request for each line.
I read the files line by line using an iterator, and a request is made for each element. It starts successfully for some lines, but at some point it starts to fail:
akka.pattern.AskTimeoutException: Ask timed out on [Actor[akka://default/user/IO-HTTP#-35162984]] after [60000 ms]
.
At first I thought I was overloading the service, so I set "spray.can.host-connector.max-connections" to 1. It works much slower, but I have the same errors.
Here is the code:
import spray.http.MediaTypes._ val EdnType = register( MediaType.custom( mainType = "application", subType = "edn", compressible = true, binary = false, fileExtensions = Seq("edn"))) val pipeline = ( addHeader("Accept", "application/json") ~> sendReceive ~> unmarshal[PipelineResponse]) def postData(data: String) = { val request = Post(pipelineUrl).withEntity(HttpEntity.apply(EdnType, data)) val responseFuture: Future[PipelineResponse] = pipeline(request) responseFuture } dataLines.map { d => val f = postData(d) f.onFailure { case e => println("Error - "+e)}
I do it this way because I don't need all the data, just some clusters.
How can I solve this problem and keep it completely async?
source share