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

Hub handshake failed with error 'NoSuchMethodError: The method 'send' was called on null. #16

Closed
nikitaabnave opened this issue Jul 30, 2020 · 4 comments

Comments

@nikitaabnave
Copy link

nikitaabnave commented Jul 30, 2020

I am trying to connect to server. But I am getting - Hub handshake failed with error 'NoSuchMethodError: The method 'send' was called on null.

Below is the Console log -

I/flutter (22642): log The HttpConnection connected successfully.
I/flutter (22642): log Sending handshake request.
I/flutter (22642): log Hub handshake failed with error 'NoSuchMethodError: The method 'send' was called on null.
I/flutter (22642): Receiver: null
I/flutter (22642): Tried calling: send("{"protocol":"json","version":1}\u001e")' during start(). Stopping HubConnection.
I/flutter (22642): log HubConnection failed to start successfully because of error '{type 'NoSuchMethodError' is not a subtype of type 'Exception'.toString}'.
E/flutter (22642): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: type 'NoSuchMethodError' is not a subtype of type 'Exception'
E/flutter (22642): #0 HubConnection._startInternal (package:signalr_core/src/hub_connection.dart:215:41)
E/flutter (22642):
E/flutter (22642): #1 HubConnection._startWithStateTransitions (package:signalr_core/src/hub_connection.dart:151:13)
E/flutter (22642): #2 HubConnection.start (package:signalr_core/src/hub_connection.dart:137:20)

Here is my code snippet -

final connection = HubConnectionBuilder().withUrl(_serverUrl,
HttpConnectionOptions(
transport:[HttpTransportType.webSockets,HttpTransportType.longPolling],
logging: (level, message) => print('log $message'),
)).withAutomaticReconnect().build();

  await connection.start();

Please help me to figure out this issue.

@Mol0ko
Copy link
Contributor

Mol0ko commented Aug 14, 2020

I think you should pass one of HttpTransportType values to transport parameter, not a list:

final connection = HubConnectionBuilder().withUrl(
    _serverUrl,
    HttpConnectionOptions(
        transport: HttpTransportType.webSockets,
        logging: (level, message) => print('log $message'),
    )
).withAutomaticReconnect().build();

Did you try this?

/// An [HttpTransportType] or [Transport] value specifying the transport to use for the connection.
final dynamic transport;

@jamiewest
Copy link
Owner

I don't love this option being dynamic, It was done to keep consistent with the ASP SignalR typescript client. I think it could be used for custom transports... I don't believe this parameter is supposed to receive a list though.

@AliEasy
Copy link

AliEasy commented Sep 1, 2020

Any solution yet?

@jamiewest
Copy link
Owner

Only a single transport can be specified, it can be an HttpTransportType (enumeration) or by an implementation of type Transport. Your code is providing a list of HttpTransportType which is not valid. If your still having issues after this correction please open another issue. Thanks

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