Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_CastError (type '_CastError' is not a subtype of type 'Exception' in type cast) #62

Open
dunghoang046 opened this issue Jun 17, 2021 · 3 comments

Comments

@dunghoang046
Copy link

dunghoang046 commented Jun 17, 2021

why using await connection.start() _CastError (type '_CastError' is not a subtype of type 'Exception' in type cast)
not connect start. I using signalr_core 1.1.1 and dotnet core 2.1

I/flutter (14152): The HttpConnection connected successfully.
I/flutter (14152): Sending handshake request.
I/flutter (14152): Hub handshake failed with error 'Null check operator used on a null value' during start(). Stopping HubConnection.
I/flutter (14152): HubConnection failed to start successfully because of error '{type '_CastError' is not a subtype of type 'Exception' in type cast.toString()}'.
E/flutter (14152): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: type '_CastError' is not a subtype of type 'Exception' in type cast

@CarvalhoWesley
Copy link

@dunghoang046, would you have an example code?

@a-bullert
Copy link

We're seeing the same issue reported via Sentry.
This is our code sample (with some irrelevant details removed):

class ACSignalRService {

static final String _signalRRoute = 'XXXXXXXXXX';

HubConnection _connection;

ACSignalRService() {
_connection = HubConnectionBuilder()
.withUrl(
_signalRRoute,
HttpConnectionOptions( ))
.build();
}

void stopConnection() {
_connection.stop();
}

Future startConnection(StreamController streamController) async {
if (_connection.state == HubConnectionState.disconnected) {
await _connection.start();
_connection.on('XXXXXX', (message) {
// doing something here
});
}
}

startConnection is called from somewhere else in our code. If we have an error on our side, it could be called multiple times.
But still, the error reported here, is a cast exception in the libraries code. This is the stack trace:

_CastError: type '_CastError' is not a subtype of type 'Exception' in type cast
File "hub_connection.dart", line 221, in HubConnection._startInternal
File "hub_connection.dart", line 154, in HubConnection._startWithStateTransitions

@DittoGod
Copy link

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants