我正在使用akka http服务器进行文件上传:
(path("file" / "upload") & post) {
formFields("formParams") { formParams =>
fileUpload("zip") {
case byteSources =>
val result = uploadTOS3(formParams, byteSources)
onSuccess(result){ res =>
complete(HttpResponse(entity = HttpEntity(ContentTypes.`application/json`, res)))
}
}
}
}
akka配置:
akka.http {
parsing.max-content-length = 1000m
parsing.max-to-strict-bytes = 100000m
server.parsing.max-to-strict-bytes = 100000m
server.parsing.max-content-length=4096m
server.request-timeout = 1500 seconds
server.idle-timeout = 1500 seconds
client.idle-timeout = 600s
client.connecting-timeout = 600s
}
版本:
val ScalaVersion = "2.13.8"
val AkkaVersion = "2.6.19"
val AkkaHttpVersion = "10.2.9"
上传文件时出现错误:
akka.http.scaladsl.model.IllegalRequestException: Request timed out after 10 seconds while waiting for entity data: Consider increasing the timeout for toStrict
[info] at akka.http.scaladsl.model.IllegalRequestException$.apply(ErrorInfo.scala:99)
[info] at akka.http.scaladsl.server.directives.BasicDirectives$$anonfun$$nestedInanonfun$toStrictEntity$3$1.applyOrElse(BasicDirectives.scala:404)
[info] at akka.http.scaladsl.server.directives.BasicDirectives$$anonfun$$nestedInanonfun$toStrictEntity$3$1.applyOrElse(BasicDirectives.scala:400)
[info] at scala.util.Failure.recover(Try.scala:233)
[info] at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:487)
[info] at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:63)
[info] at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:100)
[info] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
[info] at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:94)
[info] at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:100)
[info] at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:49)
[info] at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:48)
[info] at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
[info] at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
[info] at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
[info] at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
[info] at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
我尝试了配置更改,如超时参数,但没有帮助。任何帮助将不胜感激!!
1条答案
按热度按时间6g8kf2rb1#
我发现了问题,这里有一个解决方案。
对于Strict实体,默认超时是10秒。我尝试在配置文件中增加超时,但不起作用,因此直接添加到代码中:
也许对其他人有帮助!