spray-client for large file download

402 views
Skip to first unread message

Peter Salanki

unread,
Jul 15, 2014, 4:42:03 PM7/15/14
to spray...@googlegroups.com
Hello,

I'm trying to use spray-client to download a larger file (that takes several minutes to download).

I increased the limits in my application.conf:

spray.can {

 client {

  request-timeout = 600 s

  parsing {   

   max-content-length = 2g

   max-chunk-size  = 10m

  }

 }

Test Code:

class DownloadManager extends Actor {

  import context.dispatcher


  private val pipeline: HttpRequest => Future[HttpResponse] = sendReceive

  override def preStart(): Unit = {

   val response = pipeline(Get(url)).map(_.right) recover recoverFuture

    response onComplete  {

      case Success(r) => println(s"Response: $r")

      case Failure(ex) => println(ex, "ResponseFail")

    }

  }

  def receive: PartialFunction[Any, Unit] = {    

   case other => log.error(s"Received: $other")

  }

}


The result is always a: ResponseFail, akka.pattern.AskTimeoutException: Ask timed out on [Actor[akka://system/user/IO-HTTP#2058035398]] after [60000 ms]

There seems to be some askTimeout internal to Spray that is set to 60 seconds, can this be the case? On the wire there is roughly 30Mbytes of the file transferred before the timeout occurs, so there is stuff happening.

Sincerely,
Peter

Johannes Rudolph

unread,
Jul 16, 2014, 4:26:34 AM7/16/14
to spray...@googlegroups.com
Hi Peter,

On Tue, Jul 15, 2014 at 10:42 PM, Peter Salanki <peter....@gmail.com> wrote:
> private val pipeline: HttpRequest => Future[HttpResponse] = sendReceive

> There seems to be some askTimeout internal to Spray that is set to 60
> seconds, can this be the case? On the wire there is roughly 30Mbytes of the
> file transferred before the timeout occurs, so there is stuff happening.

Yes, `sendReceive` sets a default timeout of 60 seconds:

https://github.com/spray/spray/blob/master/spray-client/src/main/scala/spray/client/pipelining.scala#L33

You can change the value by bringing an implicit `Timeout` value with
the desired value into scope.

For example:

implicit val myTimeout: Timeout = 5.minutes
private val pipeline: HttpRequest => Future[HttpResponse] = sendReceive

--
Johannes

-----------------------------------------------
Johannes Rudolph
http://virtual-void.net
Reply all
Reply to author
Forward
0 new messages