https://kotlinlang.org logo
#ktor
Title
# ktor
t

Tim Malseed

04/30/2021, 12:29 PM
I’m having trouble getting the remote jvm debugger to attach to my ktor application. The application runs in a docker container, via
installDist
as per the documentation. Running on openjdk 11 JVM args are :
Copy code
applicationDefaultJvmArgs = listOf(
    "-Dio.ktor.development=true",
    "-Dagentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:8081"
)
I’ve exposed the port 8081.
At this point I think I’ve tried just about everything, but I get
Unable to open debugger port (localhost:8081): java.net.ConnectException “Connection refused (Connection refused)”
Any suggestions?
Is it possible that there’s some ‘debug’ flag required?
c

christophsturm

04/30/2021, 12:49 PM
i would try debugging with just a simple hello world java app first
with the debugging flags that you are setting it should just work and its not really ktor specific
t

Tim Malseed

04/30/2021, 12:52 PM
OK, that’s a good idea
The issue was the leading
D
in the jvm args
Copy code
"-Dagentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:8081"
Should be
Copy code
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:8081"
c

christophsturm

04/30/2021, 1:11 PM
ah right. that makes it almost a no-op
t

Tim Malseed

04/30/2021, 1:12 PM
But the first flag
Copy code
-Dio.ktor.development=true
Does require the ‘D’
🤯 1
Copy code
applicationDefaultJvmArgs = listOf(
    "-Dio.ktor.development=true",
    "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8081"
)
c

christophsturm

04/30/2021, 1:14 PM
yeah -D just sets an env variable. you can put anything there and will never get an error
t

Tim Malseed

04/30/2021, 1:15 PM
Ohhh! Thanks, I’ve not understood the purpose of ‘D’ in jvm flags for about 10 years
Thanks so much. This has been causing me pain all day haha
👍 1
69 Views