SignalR-Client-Swift icon indicating copy to clipboard operation
SignalR-Client-Swift copied to clipboard

Crash on ios 12 devices when skipNegotiation is true

Open mertkokusen opened this issue 2 years ago • 7 comments

Hello,

We are experiencing a crash on ios 12 devices when skipNegotiation is true.

Fatal error: 'try!' expression unexpectedly raised an error: SwiftSignalRClient.SignalRError.noSupportedTransportAvailable: file SwiftSignalRClient/HttpConnection.swift, line 72

if options.skipNegotiation { 
   transport = try! self.transportFactory.createTransport(availableTransports [TransportDescription(transportType:TransportType.webSockets, transferFormats: [TransferFormat.text, TransferFormat.binary])])
            startTransport(connectionId: nil)
}

mertkokusen avatar Sep 05 '22 06:09 mertkokusen

~~You haven't included logs so I can only suspect that WebSockets are not enabled on the server or the webSocket transport is not enabled on the server side.~~

moozzyk avatar Sep 05 '22 18:09 moozzyk

Actually, I take it back. WebSocket transport is only available on iOS 13 and newer. Negotiation can only be disabled for webSockets so if you set skipNegotiation to true it enforces using the webSocket transport which is not available on pre-iOS13 clients and hence the exception.

moozzyk avatar Sep 05 '22 18:09 moozzyk

Possibly the client should not exposed the skipNegotiation option on pre-iOS 13 as it cannot work.

moozzyk avatar Sep 05 '22 18:09 moozzyk

Thank you for the swift response. We will user other transports.

mertkokusen avatar Sep 06 '22 06:09 mertkokusen

The client should automatically pick long polling on pre-iOS13 and webSockets and n iOS13 and newer if you don’t try to skip negotiation

On Mon, Sep 5, 2022 at 11:55 PM Mert Köküşen @.***> wrote:

Thank you for the swift response. We will user other transports.

— Reply to this email directly, view it on GitHub https://github.com/moozzyk/SignalR-Client-Swift/issues/252#issuecomment-1237732807, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAK7JJDOYLR3AP2GXS5RX6DV43TGXANCNFSM6AAAAAAQEV7GC4 . You are receiving this because you commented.Message ID: @.***>

moozzyk avatar Sep 06 '22 13:09 moozzyk

We needed to skipNegotiation to force it to use web sockets to we don't need to configure sticky sessions on our load balancer. But now we will probably go with sticky sessions. Thanks again.

mertkokusen avatar Sep 06 '22 13:09 mertkokusen

Got it. Unfortunately the limitation stems from the fact that URLSessionWebSocketTask is only supported on iOS13 and newer.

moozzyk avatar Sep 07 '22 05:09 moozzyk