Skip to content

Commit df4e5d8

Browse files
author
Oleksandr Dzhychko
committed
fix(model-server): configure websockets connections to be more robust
Increase default timeout to be consistent with the LightModelServer. Enable pinging to keep connection alive. Set maxFrameSize and masking explicitly to not be affected by changing defaults
1 parent 31734d7 commit df4e5d8

File tree

1 file changed

+9
-1
lines changed
  • model-server/src/main/kotlin/org/modelix/model/server

1 file changed

+9
-1
lines changed

model-server/src/main/kotlin/org/modelix/model/server/Main.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import io.ktor.server.routing.Routing
3434
import io.ktor.server.routing.get
3535
import io.ktor.server.routing.routing
3636
import io.ktor.server.websocket.WebSockets
37+
import io.ktor.server.websocket.pingPeriod
38+
import io.ktor.server.websocket.timeout
3739
import kotlinx.html.a
3840
import kotlinx.html.h1
3941
import kotlinx.html.li
@@ -61,6 +63,7 @@ import java.io.FileReader
6163
import java.io.FileWriter
6264
import java.io.IOException
6365
import java.nio.charset.StandardCharsets
66+
import java.time.Duration
6467
import javax.sql.DataSource
6568

6669
object Main {
@@ -157,7 +160,12 @@ object Main {
157160
install(Routing)
158161
installAuthentication(unitTestMode = !KeycloakUtils.isEnabled())
159162
install(ForwardedHeaders)
160-
install(WebSockets)
163+
install(WebSockets) {
164+
pingPeriod = Duration.ofSeconds(30)
165+
timeout = Duration.ofSeconds(30)
166+
maxFrameSize = Long.MAX_VALUE
167+
masking = false
168+
}
161169
install(ContentNegotiation) {
162170
json()
163171
}

0 commit comments

Comments
 (0)