Here is a problem I encountered with akka http 10.1.12:
import java.io._
import java.nio.file.Paths
import java.security._
import akka.actor.ActorSystem
import akka.http.scaladsl._
import akka.http.scaladsl.model._
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server._
import basis.Einstellungen._
import javax.net.ssl._
import scala.concurrent._
object Main {
def main(args: Array[String]) {
implicit val system: ActorSystem = ActorSystem("myakkahttp")
implicit val executionContext: ExecutionContextExecutor = system.dispatcher
val httpRoute = Route.seal(
encodeResponse {
get {
concat(
pathSingleSlash {
val appHtml = Paths.get(static, "app.html").toFile
getFromFile(appHtml, ContentTypes.`text/html(UTF-8)`)
},
pathPrefix("static") {
getFromDirectory(static)
}
)
}
}
)
lazy val httpsConnectionContext = {
val keyStore = KeyStore.getInstance("PKCS12")
var keyStoreIS: InputStream = null
try {
keyStoreIS = new FileInputStream(keyStoreFile)
keyStore.load(keyStoreIS, keyPassword)
} catch {
case _: FileNotFoundException =>
println(s"Keystore $keyStoreFile not found.")
system.terminate()
} finally {
if (keyStoreIS != null) keyStoreIS.close()
}
val keyManagerFactory = KeyManagerFactory.getInstance("SunX509")
keyManagerFactory.init(keyStore, keyPassword)
val trustManagerFactory = TrustManagerFactory.getInstance("SunX509")
trustManagerFactory.init(keyStore)
val sslContext = SSLContext.getInstance("TLS")
sslContext.init(keyManagerFactory.getKeyManagers, trustManagerFactory.getTrustManagers, new SecureRandom)
ConnectionContext.https(
sslContext
)
}
Http().bindAndHandle(httpRoute, "0.0.0.0")
Http().bindAndHandle(httpRoute, "0.0.0.0", connectionContext = httpsConnectionContext)
}
}
app.html contains references to other JS and CSS files in directory “static”.
When requesting app.html with Firefox Browser 78.0.1 (64-Bit) some of these files get downloaded. Then suddenly loading stops at one file and all pending file requests get halted for exactly one minute. Then loading continues normally. Sometimes it gets another one-minute-halt. The problem occurs only with https, not with http.
Here is what my browser tools show:
Within the first minute:
Within the second minute:
After the second minute:
Here is the complete server log. It shows the halts for one minute from 16:54:17 to 16:55:18 and from 16:55:19 to 16:56:20:
2020-07-15 16:53:55,119 DEBUG New connection accepted
2020-07-15 16:54:09,823 INFO Slf4jLogger started
2020-07-15 16:54:09,854 DEBUG logger log1-Slf4jLogger started
2020-07-15 16:54:09,866 DEBUG Default Loggers started
2020-07-15 16:54:10,230 DEBUG Replacing JavaSerializer with DisabledJavaSerializer, due to `akka.actor.allow-java-serialization = off`.
2020-07-15 16:54:10,777 DEBUG Initializing AkkaSSLConfig extension...
2020-07-15 16:54:10,779 DEBUG buildHostnameVerifier: created hostname verifier: com.typesafe.sslconfig.ssl.NoopHostnameVerifier@5b529706
2020-07-15 16:54:12,476 DEBUG Successfully bound to /0:0:0:0:0:0:0:0:80
2020-07-15 16:54:12,661 DEBUG Successfully bound to /0:0:0:0:0:0:0:0:443
2020-07-15 16:54:16,311 DEBUG New connection accepted
2020-07-15 16:54:17,613 DEBUG Dispatcher id [akka.stream.materializer.blocking-io-dispatcher] is an alias, actual dispatcher will be [akka.actor.default-blocking-io-dispatcher]
2020-07-15 16:54:17,760 DEBUG New connection accepted
2020-07-15 16:54:17,786 DEBUG New connection accepted
2020-07-15 16:54:17,823 DEBUG New connection accepted
2020-07-15 16:54:17,873 DEBUG New connection accepted
2020-07-15 16:54:17,894 DEBUG New connection accepted
2020-07-15 16:55:18,107 DEBUG closing output
2020-07-15 16:55:18,109 DEBUG Aborting tcp connection to /77.185.185.105:36410 because of upstream failure: akka.http.impl.engine.HttpIdleTimeoutException: HTTP idle-timeout encountered, no bytes passed in the last 1 minute. This is configurable by akka.http.[server|client].idle-timeout.
2020-07-15 16:55:18,117 DEBUG Delaying cancellation for 1 minute
2020-07-15 16:55:19,442 DEBUG Aborting tcp connection to /77.185.185.105:36412 because of upstream failure: akka.http.impl.engine.HttpIdleTimeoutException: HTTP idle-timeout encountered, no bytes passed in the last 1 minute. This is configurable by akka.http.[server|client].idle-timeout.
2020-07-15 16:55:19,448 DEBUG closing output
2020-07-15 16:55:19,448 DEBUG Delaying cancellation for 1 minute
2020-07-15 16:55:19,481 DEBUG closing output
2020-07-15 16:55:19,483 DEBUG Aborting tcp connection to /77.185.185.105:36414 because of upstream failure: akka.http.impl.engine.HttpIdleTimeoutException: HTTP idle-timeout encountered, no bytes passed in the last 1 minute. This is configurable by akka.http.[server|client].idle-timeout.
2020-07-15 16:55:19,486 DEBUG Delaying cancellation for 1 minute
2020-07-15 16:55:19,551 DEBUG Aborting tcp connection to /77.185.185.105:36416 because of upstream failure: akka.http.impl.engine.HttpIdleTimeoutException: HTTP idle-timeout encountered, no bytes passed in the last 1 minute. This is configurable by akka.http.[server|client].idle-timeout.
2020-07-15 16:55:19,554 DEBUG closing output
2020-07-15 16:55:19,556 DEBUG Delaying cancellation for 1 minute
2020-07-15 16:55:19,586 DEBUG New connection accepted
2020-07-15 16:55:19,600 DEBUG Aborting tcp connection to /77.185.185.105:36420 because of upstream failure: akka.http.impl.engine.HttpIdleTimeoutException: HTTP idle-timeout encountered, no bytes passed in the last 1 minute. This is configurable by akka.http.[server|client].idle-timeout.
2020-07-15 16:55:19,605 DEBUG closing output
2020-07-15 16:55:19,605 DEBUG Delaying cancellation for 1 minute
2020-07-15 16:55:19,658 DEBUG New connection accepted
2020-07-15 16:55:19,685 DEBUG New connection accepted
2020-07-15 16:55:19,696 DEBUG New connection accepted
2020-07-15 16:55:24,676 DEBUG Delaying cancellation for 1 minute
2020-07-15 16:56:20,388 DEBUG closing output
2020-07-15 16:56:20,393 DEBUG Aborting tcp connection to /77.185.185.105:36428 because of upstream failure: akka.http.impl.engine.HttpIdleTimeoutException: HTTP idle-timeout encountered, no bytes passed in the last 1 minute. This is configurable by akka.http.[server|client].idle-timeout.
2020-07-15 16:56:20,397 DEBUG Delaying cancellation for 1 minute
2020-07-15 16:56:21,252 DEBUG Aborting tcp connection to /77.185.185.105:36422 because of upstream failure: akka.http.impl.engine.HttpIdleTimeoutException: HTTP idle-timeout encountered, no bytes passed in the last 1 minute. This is configurable by akka.http.[server|client].idle-timeout.
2020-07-15 16:56:21,256 DEBUG closing output
2020-07-15 16:56:21,258 DEBUG Delaying cancellation for 1 minute
2020-07-15 16:56:21,321 DEBUG Aborting tcp connection to /77.185.185.105:36424 because of upstream failure: akka.http.impl.engine.HttpIdleTimeoutException: HTTP idle-timeout encountered, no bytes passed in the last 1 minute. This is configurable by akka.http.[server|client].idle-timeout.
2020-07-15 16:56:21,324 DEBUG closing output
2020-07-15 16:56:21,324 DEBUG Delaying cancellation for 1 minute
I am looking forward for any help!