Is it possible to start ktor server on a random po...
# ktor
a
Is it possible to start ktor server on a random port? I am using this:
Copy code
embeddedServer(Netty, port = 0)
But I don't know where I can get the random port from. And the logs are showing it is listening on
<http://0.0.0.0:0>
y
Haven't tried it, but does this work?
Copy code
val x = embeddedServer(Netty, port = 0) {}
  x.environment.connectors.first().port
a
@yschimke I have tried that, but it returns the port that is being configured, in this case
0
. The information is in the Engine, but not being propagated back into the connectos: https://github.com/ktorio/ktor/blob/master/ktor-server/ktor-server-netty/jvm/src/io/ktor/server/netty/NettyApplicationEngine.kt#L77
👍 1