I am working with websockets and they are working ...
# ktor
k
I am working with websockets and they are working perfectly fine on Android and ios is, only issue is that when my ios app goes in background on iOS 16 socket crashes with the exception
Uncaught Kotlin exception: io.ktor.client.engine.darwin.DarwinHttpRequestException: Exception in http request: Error Domain=NSPOSIXErrorDomain Code=53 "Software caused connection abort"
Does anyone have any idea why this might be happening? I found some issue threads on issue tracker and also on github but one they are related to android and JVM secondly there is no solution mentioned.
r
Background apps are severely limited in what they can do. It seems likely the iOS is shutting the network connection down when the app is backgrounded ("Software caused connection abort"). Since the resulting
DarwinHttpRequestException
is uncaught and not declared in the Objective-C header, the app is crashing. I think you should be able to either 1) declare the exception in the Swift/Objective-C entry point of your library using
@Throws
so the exception can be propagated and handled in Swift/Objective-C, or 2) catch it in your Kotlin code.
k
Thanks bro, exception handling did the job.