Skip to content

Commit

Permalink
Merge pull request #212 from modelix/bugfix/lmx-timeouts-2
Browse files Browse the repository at this point in the history
fix(model-server): configure websockets connections to be more robust
  • Loading branch information
odzhychko authored Aug 23, 2023
2 parents 2d3d76a + df4e5d8 commit 7e9aa34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ class LightModelServer @JvmOverloads constructor(val port: Int, val rootNodeProv

fun Application.installHandlers() {
install(WebSockets) {
pingPeriod = Duration.ofSeconds(15)
timeout = Duration.ofSeconds(15)
pingPeriod = Duration.ofSeconds(30)
timeout = Duration.ofSeconds(30)
maxFrameSize = Long.MAX_VALUE
masking = false
}
Expand Down
10 changes: 9 additions & 1 deletion model-server/src/main/kotlin/org/modelix/model/server/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import io.ktor.server.routing.Routing
import io.ktor.server.routing.get
import io.ktor.server.routing.routing
import io.ktor.server.websocket.WebSockets
import io.ktor.server.websocket.pingPeriod
import io.ktor.server.websocket.timeout
import kotlinx.html.a
import kotlinx.html.h1
import kotlinx.html.li
Expand Down Expand Up @@ -61,6 +63,7 @@ import java.io.FileReader
import java.io.FileWriter
import java.io.IOException
import java.nio.charset.StandardCharsets
import java.time.Duration
import javax.sql.DataSource

object Main {
Expand Down Expand Up @@ -157,7 +160,12 @@ object Main {
install(Routing)
installAuthentication(unitTestMode = !KeycloakUtils.isEnabled())
install(ForwardedHeaders)
install(WebSockets)
install(WebSockets) {
pingPeriod = Duration.ofSeconds(30)
timeout = Duration.ofSeconds(30)
maxFrameSize = Long.MAX_VALUE
masking = false
}
install(ContentNegotiation) {
json()
}
Expand Down

0 comments on commit 7e9aa34

Please sign in to comment.