First, this is a real blocker for me on iOS 12 (maybe later iOS as well but iOS 12 does not support WebSockets so SignalR is falling back to ServerSentEvents). I have a simple SignalR scenario and I'm using Flutter stable (currently 2.2.1) and using signalr_core 1.1.1.
Everything is working great in web, Android and almost iOS 12 too - with one big problem in iOS 12.
When I "close" the screen with the physical button, and then tap it again to wake the screen, login to the device and my app is displayed - then I get an exception from the underlying connection code that signalr_core use.
This is the exception:
ClientException: Connection closed while receiving data
Stack trace:
[trace] (SSE transport) sending data. String data of length '11'.
[trace] (SSE transport) request complete. Response status: 200.
PHYSICAL TAP ON DEVICE: Turn off screen
(wait 5 seconds)
PHYSICAL TAP ON DEVICE: Turn on screen + enter passcode to get past the lock screen
[debug] HttpConnection.stopConnection(null) called while in state ConnectionState.disconnecting.
[error] Connection disconnected with error 'Exception: Server timeout elapsed without receiving a message from the server.'.
[debug] HubConnection.connectionClosed(Exception: Server timeout elapsed without receiving a message from the server.) called while in state HubConnectionState.connected.
[information] Connection reconnecting because of error: 'Exception: Server timeout elapsed without receiving a message from the server.'.
[information] Reconnect attempt number 1 will start in 0 ms.
[debug] Starting connection with transfer format 'TransferFormat.text'.
[debug] Sending negotiation request: https://my-url.com/my-hub/negotiate.
[debug] Selecting transport 'HttpTransportType.ServerSentEvents'.
[trace] (SSE transport) Connecting.
[information] SSE connected to https://my-url.com/my-hub?id=...
[debug] The HttpConnection connected successfully.
[debug] Sending handshake request.
I see this exception because I'm using Catcher (a separate pub.dev package) to catch all unhandled exceptions. So this will trigger my generic "unhandled exception" logic and create unwanted exceptions for the end users. I do not get this exception on Android. Can I somehow catch this exception or prevent signalr_core to throw it?
Because of the nature of the exception I can't seem to catch it by wrapping the connection builder or the connection start methods in try/catch.
Any ideas on how to prevent this problem?
EDIT: To be clear: the reconnect is successful and the signalr connection is working but the exception is leaking up to my application and triggering an error message for the end user. I just want to ignore this exception but that isn't possible with a generic exception handler like catcher because the exception is coming as a very generic ClientException from the http package (not signalr_core).
First, this is a real blocker for me on iOS 12 (maybe later iOS as well but iOS 12 does not support WebSockets so SignalR is falling back to ServerSentEvents). I have a simple SignalR scenario and I'm using Flutter stable (currently 2.2.1) and using signalr_core 1.1.1.
I connect like this:
Everything is working great in web, Android and almost iOS 12 too - with one big problem in iOS 12.
When I "close" the screen with the physical button, and then tap it again to wake the screen, login to the device and my app is displayed - then I get an exception from the underlying connection code that signalr_core use.
This is the exception: ClientException: Connection closed while receiving data Stack trace:
This is the log from signalr_core:
I see this exception because I'm using Catcher (a separate pub.dev package) to catch all unhandled exceptions. So this will trigger my generic "unhandled exception" logic and create unwanted exceptions for the end users. I do not get this exception on Android. Can I somehow catch this exception or prevent signalr_core to throw it?
Because of the nature of the exception I can't seem to catch it by wrapping the connection builder or the connection start methods in try/catch.
Any ideas on how to prevent this problem?
EDIT: To be clear: the reconnect is successful and the signalr connection is working but the exception is leaking up to my application and triggering an error message for the end user. I just want to ignore this exception but that isn't possible with a generic exception handler like catcher because the exception is coming as a very generic ClientException from the http package (not signalr_core).