danielspeixoto
12/09/2017, 12:15 AMlbaresse
12/12/2017, 7:26 PMAny
kotlin's type but It seems to us it was not so clean to extend it.orangy
12/12/2017, 7:52 PMsnrostov
12/12/2017, 8:34 PMarnaud.giuliani
12/13/2017, 10:56 AMorangy
12/14/2017, 5:17 PMgotwalt
12/14/2017, 6:08 PMinstall(CORS) {
method(HttpMethod.Options)
method(HttpMethod.Put)
method(HttpMethod.Delete)
header(HttpHeaders.Authorization)
allowCredentials = true
host("*", schemes = listOf("http", "https"))
}
avolkmann
12/19/2017, 7:00 AMTristan Caron
12/21/2017, 1:20 PMktor-auth-jwt
? I cannot use it. Gradle is throwing me an error cannot resolve
. But others packages are okay (ktor-auth
works for instance).spand
12/21/2017, 1:36 PMorangy
12/21/2017, 6:30 PMSessionStorage
tjb
12/27/2017, 9:18 PM@Value
from Spring in Ktor?wineluis
01/01/2018, 2:53 PMcall.respondText(json.toJsonString(), ContentType.Application.Json, HttpStatusCode.OK)
Ian
01/01/2018, 11:33 PM(index):77 WebSocket is already in CLOSING or CLOSED state
error. There is no indication that the webSocket { … }
handler is called at all.
Does anyone have any suggestions about how I can figure out why the server is closing the webSocket connection or failing to open it in the first place?
[1] https://github.com/ktorio/ktor/blob/master/ktor-samples/ktor-samples-websocket/src/io/ktor/samples/chat/ChatApplication.ktlouiscad
01/02/2018, 2:14 PMorangy
01/05/2018, 5:33 PMLucas
01/12/2018, 9:41 AMException in thread "ForkJoinPool.commonPool-worker-2 @coroutine#4" java.lang.IllegalStateException: Unsupported opcode b
at io.ktor.websocket.FrameParser.getFrameType(FrameParser.kt:26)
at io.ktor.websocket.FrameParser.parseHeader1(FrameParser.kt:69)
at io.ktor.websocket.FrameParser.handleStep(FrameParser.kt:56)
at io.ktor.websocket.FrameParser.frame(FrameParser.kt:52)
at io.ktor.websocket.WebSocketReader.parseLoop(WebSocketReader.kt:55)
at io.ktor.websocket.WebSocketReader.readLoop(WebSocketReader.kt:46)
at io.ktor.websocket.WebSocketReader$readerJob$1.doResume(WebSocketReader.kt:21)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:54)
at kotlinx.coroutines.experimental.DispatchTask.run(CoroutineDispatcher.kt:123)
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
@Test
fun `It can get a car using cars ws endpoint`() = withTestApplication(Application::main) {
val webSocketRequest = handleWebSocket("/cars", {
body = """{"model":"Ford Mustang","releaseYear":1976}"""
})
webSocketRequest.let { call ->
call.response.awaitWebSocket(Duration.ofSeconds(20))
val (model, releaseYear) = jacksonObjectMapper().readValue<Car>(call.response.content!!)
assertEquals(model, "Ford Mustang")
assertEquals(releaseYear, 1789)
}
}
routing {
val messages = ConflatedBroadcastChannel<Car>()
webSocket("/cars") {
messages.openSubscription().use { subscription ->
subscription.consumeEach {
println("Sending $it")
outgoing.send(Frame.Text(jacksonObjectMapper().writeValueAsString(it)))
}
}
}
launch {
while (isActive) {
delay(1000L)
messages.offer(Car(model = "Ford Mustang", releaseYear = 1976))
}
}
}
frellan
01/12/2018, 12:19 PMdeviant
01/12/2018, 3:57 PMfrellan
01/13/2018, 9:59 AMlocalhost:5000
and I had to enable CORS for localhost:5000
as well, which seems weird to me. I did not get the usual CORS not allowed header blabla
just a 403
wouterdoeland
01/13/2018, 8:28 PMfrellan
01/14/2018, 1:44 PMError: Main method not found in class ServerKt, please define the main method as:
public static void main(String[] args)
frellan
01/14/2018, 1:44 PMorangy
01/14/2018, 5:02 PMdamian
01/14/2018, 7:38 PMCORS
(with GET, POST, OPTIONS methods, anyHost
and exposeHeader("Access-Control-Allow-Origin")
) but i'm still receiving 403 for requestsorangy
01/15/2018, 5:39 AMalpha
elizarov
01/16/2018, 10:02 AMaeruhxi
01/16/2018, 10:44 AMinstall(ContentNegotiation) {
gson {
setDateFormat(DateFormat.LONG)
excludeFieldsWithoutExposeAnnotation()
}
}
Even with excludeFieldsWithoutExposeAnnotation
, it is serializing fields without Expose. Am I missing something?Sergey Chikin
01/16/2018, 11:53 AMoverride val route: Routing.() -> Unit
get() = {
get("healthz") {
val dbState = asyncGetDatabaseState()
var res = HealthModel(
status = Server.status,
database = dbState.await(),
redis = RedisHealth("null", 0)
)
call.respond(res)
}
}
suspend fun getDatabaseState(): DatabaseHealth {
delay(500) //sleep for 500ms
return DatabaseHealth(
host = Config.config[DatabaseConfig.host],
database = Config.config[DatabaseConfig.database],
latencyMs = 500
)
}
fun asyncGetDatabaseState() = async {
getDatabaseState()
}
But I keep getting Caused by: io.ktor.server.engine.BaseApplicationResponse$ResponseAlreadySentException: Response has already been sent
even though actual content is sent back to client with HTTP 200. What am I doing wrong?Muthu Nadar
01/16/2018, 1:57 PMMuthu Nadar
01/16/2018, 1:57 PMorangy
01/16/2018, 2:44 PMMuthu Nadar
01/17/2018, 7:30 AM