Hello, I’m getting some invalid websocket frames w...
# ktor
j
Hello, I’m getting some invalid websocket frames which cause an
IllegalStateException
in the
FrameParser
, and I could not find a way to catch those before they are handled in
defaultEnginePipeline
. I tried passing a coroutine exception handler as parent coroutine context to the application, the status page plugin, and an interceptor on
CallFailed
- all without success. Is there a way to correctly handle that exception? I’m probably missing something obvious. Or is it possible to customize / override the behavior of
logFailure
in the
DefaultEnginePipeline
?
a
Can you please share the stack trace of such an exception?
j
of course, here it is:
Copy code
101 Switching Protocols: GET - /graphql-subscriptions

java.lang.IllegalStateException: Unsupported opcode b
	at io.ktor.websocket.FrameParser.getFrameType(FrameParser.kt:41)
	at io.ktor.websocket.FrameParser.parseHeader1(FrameParser.kt:101)
	at io.ktor.websocket.FrameParser.handleStep(FrameParser.kt:73)
	at io.ktor.websocket.FrameParser.frame(FrameParser.kt:68)
	at io.ktor.websocket.WebSocketReader.parseLoop(WebSocketReader.kt:83)
	at io.ktor.websocket.WebSocketReader.readLoop(WebSocketReader.kt:74)
	at io.ktor.websocket.WebSocketReader.access$readLoop(WebSocketReader.kt:24)
	at io.ktor.websocket.WebSocketReader$readLoop$1.invokeSuspend(WebSocketReader.kt)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:100)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
a
I don't think there is a way to handle such exceptions. So you don't want to see them in the logs?
j
Yes, error logs trigger an alert, and that’s kind of annoying. But if there is no way to handle that exception, we’ll just filter it. Thank you for looking into it!