Nicolas
06/18/2025, 12:16 PMfun Application.configureWebSocket(){
install(WebSockets) {
pingPeriod = 15.seconds
timeout = 15.seconds
maxFrameSize = kotlin.Long.MAX_VALUE
masking = false
}
}
routing {
webSocket("ws") {
val token = call.request.queryParameters["token"]
if (token == null) {
close(CloseReason(CloseReason.Codes.VIOLATED_POLICY, "No Token"))
return@webSocket
}
val decodedJWT = try { JwtFactory.buildverifier().verify(token) }
catch (e: Exception) {
close(CloseReason(CloseReason.Codes.VIOLATED_POLICY, "Invalid Token: ${e.message}"))
return@webSocket
}
val userId: UUID = try { UUID.fromString(decodedJWT.getClaim(JwtClaimConstant.claimUserId).asString()) }
catch (e: Exception) {
close(CloseReason(CloseReason.Codes.VIOLATED_POLICY, "Invalid Token: ${e.message}"))
return@webSocket
}
val sessionId = decodedJWT.id?.let {
runCatching { UUID.fromString(it) }.getOrNull()
} ?: run {
close(CloseReason(CloseReason.Codes.VIOLATED_POLICY, "Invalid or missing sessionId (jti)"))
return@webSocket
}
<http://logger.info|logger.info>("$userId is connected")
try {
println("$userId start")
incoming.consumeEach {
when (it) {
is Frame.Text -> {
val text = it.readText()
println("tototot $userId Received: $text")
}
is Frame.Close -> {
println("tototot $userId WebSocket closed by server with reason: ${it.readReason()}")
}
is Frame.Ping -> {
println("tototot $userId ping: $it")
}
is Frame.Pong -> {
println("tototot $userId pong: $it")
} else -> {
println("tototot $userId else: $it")
}
}
}
} catch (e: Exception) {
println("$userId error $e")
} finally {
println("$userId finally remove")
}
println("$userId end")
}
}
and I found something weird If I open a websocket on my iOS phone, turnoff the internet (and close my phone) I keep logging this on KTOR:
io.ktor.websocket.WebSocket - WebSocket Pinger: received valid pong frame Frame PONG
For me if I close my phone the webscket should try a ping and should not receive a pong and close, For me the goal of ping pong is to avoid all this. I am not sure if I have doing everything good 🙂
I am hosting my server on Render
Thank you in advance for your timedave
06/18/2025, 12:27 PMNicolas
06/23/2025, 9:27 AMAsadullah Nadeem
06/24/2025, 8:43 AMBharat Kumar
06/26/2025, 10:26 AMAlina Dolgikh [JB]
bk9735732777
07/03/2025, 6:36 AM# Stage 1: Cache Gradle dependencies
FROM gradle:latest AS cache
RUN mkdir -p /home/gradle/cache_home
ENV GRADLE_USER_HOME=/home/gradle/cache_home
COPY build.gradle.* gradle.properties /home/gradle/app/
COPY gradle /home/gradle/app/gradle
WORKDIR /home/gradle/app
RUN gradle clean build -i --stacktrace
# Stage 2: Build Application
FROM gradle:latest AS build
COPY --from=cache /home/gradle/cache_home /home/gradle/.gradle
COPY --chown=gradle:gradle . /home/gradle/src
WORKDIR /home/gradle/src
# Build the fat JAR, Gradle also supports shadow
# and boot JAR by default.
RUN gradle buildFatJar --no-daemon
# Stage 3: Create the Runtime Image
FROM amazoncorretto:22 AS runtime
EXPOSE 8080
RUN mkdir /app
COPY --from=build /home/gradle/src/build/libs/*.jar /app/ktor-docker-sample.jar
ENTRYPOINT ["java","-jar","/app/ktor-docker-sample.jar"]
This is my docker file
Thread in Slack ConversationOhiorenua Aigboje
07/08/2025, 12:47 PMOhiorenua Aigboje
07/14/2025, 6:39 AMJens Alfke
07/19/2025, 6:31 PMjoseph_ivie
07/23/2025, 2:54 PMJoel Denke
08/04/2025, 3:13 PMMattF
08/05/2025, 12:29 PMMohammad Zaki
08/05/2025, 6:45 PMval response = http.get("<http://127.0.0.1:8080/v1/flashcards?topic=Something&type=quiz&difficulty=hard>")
response.bodyAsText()
Can anyone help?Joel Denke
08/07/2025, 5:20 AMJonasBecker
08/14/2025, 10:03 AMAozen
09/08/2025, 12:02 PMالخبرات العلمية ScienceExperts
09/30/2025, 6:59 AMTom Molloy
10/03/2025, 6:27 AMRoger Roca (rogydev)
10/07/2025, 10:04 AMDequency Yates
10/07/2025, 6:10 PM최민규
10/09/2025, 10:53 AMMohammad Zaki
10/09/2025, 11:40 AMYorgos S.
10/16/2025, 5:31 PMPitam Poudel
10/18/2025, 4:30 AMAaron Freeman
10/28/2025, 5:07 AMNatalia Mishina
11/06/2025, 12:39 PMTor Egil
11/07/2025, 9:38 AMpurezen
11/08/2025, 6:36 AMMarcello
11/13/2025, 2:57 PMplugins {
kotlin("jvm") version "1.9.25"
kotlin("plugin.spring") version "1.9.25"
kotlin("plugin.jpa") version "2.0.21"
id("org.springframework.boot") version "3.5.7"
id("io.spring.dependency-management") version "1.1.7"
}
group = "eu.project"
version = "0.0.1-SNAPSHOT"
description = "Demo project for Spring Boot"
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
repositories {
mavenCentral()
}
dependencies {...}
kotlin {
compilerOptions {
freeCompilerArgs.addAll("-Xjsr305=strict")
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<JavaCompile> {
options.release.set(17)
}
The error from build logs:
Build failed with an exception.
• What went wrong:
Could not determine the dependencies of task ':compileKotlin'.Cannot find a Java installation on your machine (Linux 6.1.0-37-cloud-amd64 amd64) matching: {languageVersion=17, vendor=any vendor, implementation=vendor-specific, nativeImageCapable=false}. Toolchain download repositories have not been configured. What's the issue? I used to deploy another spring boot app the same way c.a. three months ago and everything was fine.