Hello, I'm using ktor 1.2.2 and using ktor web soc...
# ktor
a
Hello, I'm using ktor 1.2.2 and using ktor web socket client in Android, all seems ok, but if user enters airplane mode or disables internet it gets app crash with exception:
Copy code
java.io.IOException: Software caused connection abort
        at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
        at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
        at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
        at sun.nio.ch.IOUtil.read(IOUtil.java:192)
        at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:382)
        at kotlinx.io.nio.ChannelsKt.read(Channels.kt:117)
        at io.ktor.network.sockets.CIOReaderKt$attachForReadingDirectImpl$1$1.invokeSuspend(CIOReader.kt:75)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.ResumeModeKt.resumeMode(ResumeMode.kt:67)
        at kotlinx.coroutines.DispatchedKt.resume(Dispatched.kt:309)
        at kotlinx.coroutines.DispatchedKt.resumeUnconfined(Dispatched.kt:49)
        at kotlinx.coroutines.DispatchedKt.dispatch(Dispatched.kt:295)
        at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:250)
        at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:260)
        at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:189)
        at io.ktor.network.selector.SelectorManagerSupport.handleSelectedKey(SelectorManagerSupport.kt:83)
        at io.ktor.network.selector.SelectorManagerSupport.handleSelectedKeys(SelectorManagerSupport.kt:63)
        at io.ktor.network.selector.ActorSelectorManager.process(ActorSelectorManager.kt:74)
        at io.ktor.network.selector.ActorSelectorManager$process$1.invokeSuspend(ActorSelectorManager.kt)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
I've added everythere try catch blocks but still this exception was not caught anywhere. Maybe anyone can help me how to overcome this?
m
do you directly wrap the ktor call in a
try/catch
block ?
I've had success wrapping
client.get {}
with 1.2.2