Giter Site home page Giter Site logo

signalr_core's Introduction

Introduction

ASP.NET Core SignalR is an open-source library that simplifies adding real-time web functionality to apps. Real-time web functionality enables server-side code to push content to clients instantly. It's platform-independent, and can be used on both the command-line and the browser.

Example

final connection = HubConnectionBuilder().withUrl('http://localhost:5000/chatHub', 
    HttpConnectionOptions(
        logging: (level, message) => print(message),
    )).build();
 
await connection.start();

connection.on('ReceiveMessage', (message) {
    print(message.toString());
});

await connection.invoke('SendMessage', args: ['Bob', 'Says hi!']);

signalr_core's People

Contributors

anisalibegic avatar bennibau avatar chris-gander avatar fafre avatar jamiewest avatar janjoosse avatar jddl avatar mol0ko avatar paulquinn avatar rcsandberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

signalr_core's Issues

Cannot establish a connection with a token

Hi,

First of all, thank you for this wonderful work.

I started using the library but I have a problem when connecting with a BearerToken.

On the server side, the OnConnectedAsync method is never called.

I did a test run with the C # signal client, I am not experiencing the problem.

Logs
I/flutter ( 6194): Starting HubConnection.
I/flutter ( 6194): Starting connection with transfer format 'TransferFormat.text'.
I/flutter ( 6194): Sending negotiation request: http://192.168.1.38:55001/messaging/negotiate.
I/flutter ( 6194): Selecting transport 'HttpTransportType.webSockets'.
I/flutter ( 6194): (WebSockets transport) Connecting.
I/flutter ( 6194): The HttpConnection connected successfully.
I/flutter ( 6194): Sending handshake request.
I/flutter ( 6194): (WebSockets transport) sending data. String data of length '32'.
I/flutter ( 6194): Using HubProtocol 'json'.
I/flutter ( 6194): (WebSockets transport) socket closed.
I/flutter ( 6194): HttpConnection.stopConnection(null) called while in state ConnectionState.disconnecting.
I/flutter ( 6194): Connection disconnected with error 'Exception: Server timeout elapsed without receiving a message from the server.'.
I/flutter ( 6194): HubConnection.connectionClosed(Exception: Server timeout elapsed without receiving a message from the server.) called while in state HubConnectionState.disconnected.
I/flutter ( 6194): Hub handshake failed with error 'Exception: Server timeout elapsed without receiving a message from the server.' during start(). Stopping HubConnection.
I/flutter ( 6194): Call to HttpConnection.stop(Exception: Server timeout elapsed without receiving a message from the server.) ignored because the connection is already in the disconnected state.
I/flutter ( 6194): HubConnection failed to start successfully because of error '{Exception: Server timeout elapsed without receiving a message from the server..toString}'.
E/flutter ( 6194): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Exception: Server timeout elapsed without receiving a message from the server.

Thank you for your help

Mohamed

Exception: WebSocket closed with status code: 1002 (null).

version : signalr_core: ^1.1.1

final options = HttpConnectionOptions(
      accessTokenFactory: () async => "${_authFacade.token}",
      transport: HttpTransportType.webSockets,
      logging: (level, message) => print('$level: $message'),
    );
if (this.hubConnection == null) {
      this.hubConnection = HubConnectionBuilder()
          .withUrl(
            "$BASE_URL/v2/notificationHub",
            options,
          )
          .withAutomaticReconnect()
          .build();
}

Log

I/flutter ( 9907): LogLevel.debug: Sending handshake request.
I/flutter ( 9907): LogLevel.trace: (WebSockets transport) sending data. String data of length '32'.
I/flutter ( 9907): LogLevel.information: Using HubProtocol 'json'.
I/flutter ( 9907): LogLevel.trace: (WebSockets transport) socket closed.
I/flutter ( 9907): LogLevel.debug: HttpConnection.stopConnection(Exception: WebSocket closed with status code: 1002 (null).) called while in state ConnectionState.connected.
I/flutter ( 9907): LogLevel.error: Connection disconnected with error 'Exception: WebSocket closed with status code: 1002 (null).'.
I/flutter ( 9907): LogLevel.debug: HubConnection.connectionClosed(Exception: WebSocket closed with status code: 1002 (null).) called while in state HubConnectionState.connecting.
I/flutter ( 9907): LogLevel.debug: HttpConnection.stopConnection(null) called while in state ConnectionState.disconnected.
I/flutter ( 9907): LogLevel.debug: Call to HttpConnection.stopConnection(null) was ignored because the connection is already in the disconnected state.
I/flutter ( 9907): LogLevel.debug: Hub handshake failed with error 'Exception: WebSocket closed with status code: 1002 (null).' during start(). Stopping HubConnection.
I/flutter ( 9907): LogLevel.debug: Call to HttpConnection.stop(Exception: WebSocket closed with status code: 1002 (null).) ignored because the connection is already in the disconnected state.
I/flutter ( 9907): LogLevel.debug: HubConnection failed to start successfully because of error '{Exception: WebSocket closed with status code: 1002 (null)..toString()}'.
I/flutter ( 9907): Exception: WebSocket closed with status code: 1002 (null).

[Web] [Dev Channel] Hub handshake failed with error 'NoSuchMethodError:

The following messages are logged:

Selecting transport 'HttpTransportType.webSockets'.
(WebSockets transport) Connecting.
The HttpConnection connected successfully.
Sending handshake request.
(WebSockets transport) sending data. String data of length '32'.
Hub handshake failed with error 'NoSuchMethodError: invalid member on null: 'sink'' during start(). Stopping HubConnection.
HubConnection failed to start successfully because of error '{Expected a value of type 'Exception', but got one of type 'JSNoSuchMethodError'.toString}'.
Expected a value of type 'Exception', but got one of type 'JSNoSuchMethodError'

I've tracked this down to an issue with _createConnectUrl in http_connection.dart. The function will generate a string that ends with a "#" if there is no uri.fragment. This can be corrected by doing the following:

return Uri(
      scheme: uri.scheme,
      host: uri.host,
      port: uri.port,
      path: uri.path,
      fragment: uri.fragment.isNotEmpty ? uri.fragment : null,
      queryParameters: <String, dynamic>{
        ...uri.queryParameters,
        ...{'id': connectionToken},
      },
    ).toString();

Duplicate connections on hot restart, any way to close all connections without handles to them?

Hi,

I'm trying this lib but I get multiple connections when using hot restart (both on mobile and web). This isn't a big issue in mobile since the end users in production cannot "hot restart" the app with flutter for web, an end user can refresh the browser at any given time and thus creating multiple connections.

This is easy to reproduce, just connect in initState() or something similar, like the example:

final connection = HubConnectionBuilder().withUrl('http://localhost:5000/chatHub', 
    HttpConnectionOptions(
        logging: (level, message) => print(message),
    )).build();
 
await connection.start();

connection.on('ReceiveMessage', (message) {
    print(message.toString());
});

await connection.invoke('SendMessage', args: ['Bob', 'Says hi!']);

With a server that can accept "SendMessage" and that replies with "ReceiveMessage" we will get an output in the debug console: Bob Says hi!.

This is great, just like we want. We will close the socket on dispose() but with hot restart we are not calling dispose() (at least not in flutter for web).

But after hot restart, initState will initialize a connection but the old one is still there! So we get two lines in debug console:
Bob Says hi!
Bob Says hi!

If we hot restart again, we have three connections:
Bob Says hi!
Bob Says hi!
Bob Says hi!

This is can be solved by closing all connections before creating a new one, either automatically or expose a "closeAllConnections()" call. I've seen that adhara_socket_io library has this in their 1.0.0 release (https://pub.dev/packages/adhara_socket_io/changelog#100---3rd-apr-2020)

I also saw this related answer to a similar post on an issue for adhara_socket_io: infitio/flutter_socket_io#6 (comment)

Any way that I can achieve this with current version of signalr_core lib?

Azure Signalr

I'm a bit (pun) unclear of the URL form when making a Flutter Client connection to an Azure Signalr Hub.

Examples are far and few to come by on the internet and everything I try returns a 404 or 400 error.

Has this been tested with Azure?

Johnny

Unnecessary use of tuple 3rd party package

The tuple data structure is too simple and there is no reason to use 3rd party packages. You can always create your own class with 2 fields and do whatever you want. The 3rd party packages cause dependency conflicts. Sometimes it can be very nasty. Here is the problem which I have encountered.

Because no versions of signalr_core match >1.1.1 <2.0.0 and signalr_core 1.1.1 depends on tuple ^2.0.0, signalr_core ^1.1.1 requires tuple ^2.0.0.
And because no versions of tuple match >2.0.0 <3.0.0 and tuple 2.0.0 depends on quiver ^3.0.0, signalr_core ^1.1.1 requires quiver ^3.0.0.
And because flutter_layout_grid 0.10.5 depends on quiver ^2.0.0 and no versions of flutter_layout_grid match >0.10.5 <0.11.0, signalr_core ^1.1.1 is incompatible with flutter_layout_grid ^0.10.5.
And because flutter_html 1.3.0 depends on flutter_layout_grid ^0.10.5 and no versions of flutter_html match >1.3.0 <2.0.0, signalr_core ^1.1.1 is incompatible with flutter_html ^1.3.0.
So, because aura_mobile depends on both flutter_html ^1.3.0 and signalr_core ^1.1.1, version solving failed.
pub get failed (1; So, because aura_mobile depends on both flutter_html ^1.3.0 and signalr_core ^1.1.1, version solving failed.)

Please, stay away from 3rd party packages as much as you can and remove those which you can easily make yourself.

Completion message parsing error 'NoSuchMethodError'

I can successfully connect to server and get success message from logger like this:

I/flutter (12538): (WebSockets transport) data received. String data of length '3'. Content: '{}'
I/flutter (12538): Server handshake complete.
I/flutter (12538): HubConnection connected successfully.

But after further call invoke method of HubConnection and get a valid json response with type 3 (completion) I am getting an error. Here is long debug log of an error:

E/flutter (12538): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: type 'NoSuchMethodError' is not a subtype of type 'Exception'
E/flutter (12538): #0      WebSocketTransport.connect.<anonymous closure> 
package:signalr_core/…/transports/web_socket_transport.dart:79
E/flutter (12538): #1      _rootRunUnary  (dart:async/zone.dart:1198:47)
E/flutter (12538): #2      _CustomZone.runUnary  (dart:async/zone.dart:1100:19)
E/flutter (12538): #3      _CustomZone.runUnaryGuarded  (dart:async/zone.dart:1005:7)
E/flutter (12538): #4      _BufferingStreamSubscription._sendData  (dart:async/stream_impl.dart:357:11)
E/flutter (12538): #5      _BufferingStreamSubscription._add  (dart:async/stream_impl.dart:285:7)
E/flutter (12538): #6      _ForwardingStreamSubscription._add  (dart:async/stream_pipe.dart:127:11)
E/flutter (12538): #7      _HandleErrorStream._handleData  (dart:async/stream_pipe.dart:266:10)
E/flutter (12538): #8      _ForwardingStreamSubscription._handleData  (dart:async/stream_pipe.dart:157:13)
E/flutter (12538): #10     _CustomZone.runUnary  (dart:async/zone.dart:1100:19)
E/flutter (12538): #9      _rootRunUnary  (dart:async/zone.dart:1198:47)
E/flutter (12538): #11     _CustomZone.runUnaryGuarded  (dart:async/zone.dart:1005:7)
E/flutter (12538): #12     _BufferingStreamSubscription._sendData  (dart:async/stream_impl.dart:357:11)
E/flutter (12538): #13     _BufferingStreamSubscription._add  (dart:async/stream_impl.dart:285:7)
E/flutter (12538): #14     _SyncStreamControllerDispatch._sendData  (dart:async/stream_controller.dart:808:19)
E/flutter (12538): #15     _StreamController._add  (dart:async/stream_controller.dart:682:7)
E/flutter (12538): #16     _StreamController.add  (dart:async/stream_controller.dart:624:5)
E/flutter (12538): #17     new _WebSocketImpl._fromSocket.<anonymous closure>  (dart:_http/websocket_impl.dart:1145:21)
E/flutter (12538): #18     _rootRunUnary  (dart:async/zone.dart:1198:47)
E/flutter (12538): #19     _CustomZone.runUnary  (dart:async/zone.dart:1100:19)
E/flutter (12538): #20     _CustomZone.runUnaryGuarded  (dart:async/zone.dart:1005:7)
E/flutter (12538): #21     _BufferingStreamSubscription._sendData  (dart:async/stream_impl.dart:357:11)
E/flutter (12538): #22     _BufferingStreamSubscription._add  (dart:async/stream_impl.dart:285:7)
E/flutter (12538): #23     _SinkTransformerStreamSubscription._add  (dart:async/stream_transformers.dart:69:11)
E/flutter (12538): #24     _EventSinkWrapper.add  (dart:async/stream_transformers.dart:15:11)
E/flutter (12538): #25     _WebSocketProtocolTransformer._messageFrameEnd  (dart:_http/websocket_impl.dart:338:23)
E/flutter (12538): #26     _WebSocketProtocolTransformer.add  (dart:_http/websocket_impl.dart:232:46)
E/flutter (12538): #27     _SinkTransformerStreamSubscription._handleData  (dart:async/stream_transformers.dart:121:24)
E/flutter (12538): #28     _rootRunUnary  (dart:async/zone.dart:1198:47)
E/flutter (12538): #29     _CustomZone.runUnary  (dart:async/zone.dart:1100:19)
E/flutter (12538): #30     _CustomZone.runUnaryGuarded  (dart:async/zone.dart:1005:7)
E/flutter (12538): #31     _BufferingStreamSubscription._sendData  (dart:async/stream_impl.dart:357:11)
E/flutter (12538): #32     _BufferingStreamSubscription._add  (dart:async/stream_impl.dart:285:7)
E/flutter (12538): #33     _SyncStreamControllerDispatch._sendData  (dart:async/stream_controller.dart:808:19)
E/flutter (12538): #34     _StreamController._add  (dart:async/stream_controller.dart:682:7)
E/flutter (12538): #35     _StreamController.add  (dart:async/stream_controller.dart:624:5)
E/flutter (12538): #36     _Socket._onData  (dart:io-patch/socket_patch.dart:2020:41)
E/flutter (12538): #37     _rootRunUnary  (dart:async/zone.dart:1198:47)
E/flutter (12538): #38     _CustomZone.runUnary  (dart:async/zone.dart:1100:19)
E/flutter (12538): #39     _CustomZone.runUnaryGuarded  (dart:async/zone.dart:1005:7)
E/flutter (12538): #40     _BufferingStreamSubscription._sendData  (dart:async/stream_impl.dart:357:11)
E/flutter (12538): #41     _BufferingStreamSubscription._add  (dart:async/stream_impl.dart:285:7)
E/flutter (12538): #42     _SyncStreamControllerDispatch._sendData  (dart:async/stream_controller.dart:808:19)
E/flutter (12538): #43     _StreamController._add  (dart:async/stream_controller.dart:682:7)
E/flutter (12538): #44     _StreamController.add  (dart:async/stream_controller.dart:624:5)
E/flutter (12538): #45     _RawSecureSocket._sendReadEvent  (dart:io/secure_socket.dart:1002:19)
E/flutter (12538): #46     _rootRun  (dart:async/zone.dart:1182:47)
E/flutter (12538): #47     _CustomZone.run  (dart:async/zone.dart:1093:19)
E/flutter (12538): #48     _CustomZone.runGuarded  (dart:async/zone.dart:997:7)
E/flutter (12538): #49     _CustomZone.bindCallbackGuarded.<anonymous closure>  (dart:async/zone.dart:1037:23)
E/flutter (12538): #50     _rootRun  (dart:async/zone.dart:1190:13)
E/flutter (12538): #51     _CustomZone.run  (dart:async/zone.dart:1093:19)
E/flutter (12538): #52     _CustomZone.bindCallback.<anonymous closure>  (dart:async/zone.dart:1021:23)
E/flutter (12538): #53     Timer._createT

Here is my code:

/// _hubConnection is an instance of [HubConnection]
await _hubConnection.start();
if (_hubConnection.state == HubConnectionState.connected) {
    await _hubConnection.invoke('method', args: [arg1, arg2])
}

Recommendations and best practices?

Hi,

Awesome job providing this!

This is obviously not an bug/issue, and can of course be answered with the phrase "it depends..." :)
But I'm wondering if you have any implementation best practices on the Flutter side of things working with this?
Signal-R is new to me so I'm not sure about common patterns.

For instance, is it best practice to keep a connection to the server open for the entire app and use that as a (lazy)singleton? How and when do you close the connection? Do you e.g. usually close the connection when the app is minimized? Or do you setup a new HubConnection for each route in the app when needed and close each connection "as soon as possible"?

In my case, and I guess this is a common vanilla case:

  • I will only use one hub
  • Different routes in my app will listen to different events
  • The events will typically just trigger a page refresh or trigger a page transition based on a user's previous action

If you have any open source code that I could get inspired by I would happily check it out.

If this is too vague, feel free to close this :)

BR,
Robert

Execute function on reconnect

This is not an issue but more like enhancement. When I use a function "withAutomaticReconnect()", it is a great feature and I get automatically reconnected to the hub. But when the device joins the hub, I send a set of commands to "group" devices. With automatic reconnect, I have to write a logic to keep track of my connection state and re-join a group on a signalR hub. It would be nice if I could provide to "withAutomaticReconnect()" a function to execute upon successful reconnect, that way I can write in a code "when you reconnect, send this to the hub to join your group to start receiving data". Hopefully, it would be on your road map down the road :)

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

I'm afraid I still receive this error. See #16

I have:

final connection = HubConnectionBuilder()
         .withUrl(
             url,
             HttpConnectionOptions(
               transport: HttpTransportType.webSockets,
               accessTokenFactory: _authService.getToken,
               logMessageContent: true,
               logging: (level, message) => print(message),
             ))
         .build();

     await connection.start();
     ...

I can call negotiate successfully but during handshake it breaks:

I/flutter ( 8194): Starting HubConnection.
I/flutter ( 8194): Starting connection with transfer format 'TransferFormat.text'.
I/flutter ( 8194): Sending negotiation request: https://10.0.2.2:44302/api/signalr/negotiate.
I/flutter ( 8194): The HttpConnection connected successfully.
I/flutter ( 8194): Sending handshake request.
I/flutter ( 8194): Hub handshake failed with error 'NoSuchMethodError: The method 'send' was called on null.
I/flutter ( 8194): Receiver: null
I/flutter ( 8194): Tried calling: send("{\"protocol\":\"json\",\"version\":1}\u001e")' during start(). Stopping HubConnection.
I/flutter ( 8194): type 'NoSuchMethodError' is not a subtype of type 'Exception'
I/flutter ( 8194): HubConnection failed to start successfully because of error '{type 'NoSuchMethodError' is not a subtype of type 'Exception'.toString}'.

Using it with signalR on azure.
I can change the transporttype, but it does result in the same error.

Support MessagePack

Would be nice to know if you plan to add MessagePack support in the future.

missing methods for lifecycle events

I am trying to know when my client disconnected or connected.
I would recommend adding onOpen/onStart/onConnected callback.

The best thing would be to do something like:

class HubConnection ... {
   final _state =  BehaviourSubjscet<HubConnectionState>. seeded(HubConnectionState.disconnected);

   HubConnectionState get state => _state.value

   Stream get onConnected => _state.where(s => s == HubConnectionState.connected);
   Stream get onDisconnected => _state.where(s => s == HubConnectionState.disconnected);
   Stream get onConnecting => _state.where(s => s == HubConnectionState.connecting);
   ...
}

all you need to do now is to change all assignments of state to _state.add(HubConnectionState.whateverState) and when using the client now i can get all the info i need for lifecycle events.

My hubconnection is not stopping

image

image

I'm trying stop my hub connection after logout
image

But the stop is not working. The code stuck on "await con.stop()" forever

ed1:
It will be stuck on disconnecting forever, I will create another connection, but the stop method should be working, right?
image

Cannot connect to Azure SignalR Service

Describe the bug

I am using the package to connect to Azure SignalR Service. The negotiate endpoint on my .NET Core app is working as expected, returning a 200 OK and the corresponding url and access token, which are then used by this package to connect to Azure SignalR Service.

However, while making the connection I run in the following error, it looks like it's failing because of a type cast failure.

flutter: Starting HubConnection.
flutter: Starting connection with transfer format 'TransferFormat.text'.
flutter: Sending negotiation request: https://localhost:5001/messagehub/negotiate.
flutter: Sending negotiation request: https://*******.service.signalr.net/client/negotiate?hub=messagehub&asrs.op=%2Fmessagehub&asrs_request_id=0D%2Bm4VE2AAA%3D.
flutter: Selecting transport 'HttpTransportType.webSockets'.
flutter: (WebSockets transport) Connecting.
flutter: Failed to start the transport 'HttpTransportType.webSockets': type 'Future<String?>' is not a subtype of type 'FutureOr<String>' in type cast
flutter: Skipping transport 'HttpTransportType.serverSentEvents' because it was disabled by the client.
flutter: Skipping transport 'HttpTransportType.longPolling' because it was disabled by the client.
flutter: The HttpConnection connected successfully.
flutter: Sending handshake request.
flutter: Hub handshake failed with error 'Exception: WebSocket is not in the OPEN state' during start(). Stopping HubConnection.

Expected behavior
To succeed in making a connection.

I have created a Flutter project which can be used to reproduce the bug: https://github.com/janjoosse/SignalR_Core. Obviously reproducing it requires an Azure SignalR Service and backend API to get the url and accessToken to connect to Azure SignalR Service.

Does someone know what is causing this failure?

Is it possible to set up custom headers during handshake

In nodeJS package for signalR there is an ability to set headers that can be parsed in connect/disconnect events on the server (in case of HTTP handshake).

https://www.npmjs.com/package/@microsoft/signalr

Is it possible to add such ability there?

IHttpConnectionOptions.d.ts

interface IHttpConnectionOptions {
    /** {@link @microsoft/signalr.MessageHeaders} containing custom headers to be sent with every HTTP request. Note, setting headers in the browser will not work for WebSockets or the ServerSentEvents stream. */
    headers?: MessageHeaders;
    httpClient?: HttpClient;
    transport?: HttpTransportType | ITransport;
    logger?: ILogger | LogLevel;
    logMessageContent?: boolean;
    skipNegotiation?: boolean;
    withCredentials?: boolean;
}

[Web] Failed to complete negotiation with the server: XMLHttpRequest error.

version : signalr_core: ^1.0.5
code :

    final connection = HubConnectionBuilder()
        .withUrl(
            "$kBaseUrl/serverpush",
            HttpConnectionOptions(
              logging: (level, message) => print('$level: $message'),
            ))
        .build();

    await connection.start();

    connection.on('FlutterRecMsgFromHub', (message) {
      print(message.toString());
    });

Issues :
Restarted application in 670ms.
LogLevel.debug: Starting HubConnection.
LogLevel.debug: Starting connection with transfer format 'TransferFormat.text'.
LogLevel.debug: Sending negotiation request: https://p4infrdevsignalrwebapp01.azurewebsites.net/serverpush/negotiate.
LogLevel.error: Failed to complete negotiation with the server: XMLHttpRequest error.
LogLevel.error: Failed to start the connection: XMLHttpRequest error.
LogLevel.debug: HubConnection failed to start successfully because of error '{XMLHttpRequest error..toString}'.
Error: XMLHttpRequest error.
at Object.createErrorWithStack (http://localhost:63192/dart_sdk.js:4362:12)
at Object._rethrow (http://localhost:63192/dart_sdk.js:38245:16)
at async._AsyncCallbackEntry.new.callback (http://localhost:63192/dart_sdk.js:38239:13)
at Object._microtaskLoop (http://localhost:63192/dart_sdk.js:38071:13)
at _startMicrotaskLoop (http://localhost:63192/dart_sdk.js:38077:13)
at http://localhost:63192/dart_sdk.js:33574:9

Pub Get Failed

Because every version of signalr_core depends on web_socket_channel ^1.1.0 and skipq depends on web_socket_channel ^2.0.0, signalr_core is forbidden.
So, because skipq depends on signalr_core ^1.0.8, version solving failed.

When I compared my pubspec.yaml with the one in repository, I have the same version of Web Socket. But apparently I am still stuck.

Exceptions are leaking up to my application (iOS <13 only?) - can I prevent this or catch them?

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:

final connection = HubConnectionBuilder().withUrl(
  webSocketUrl,
  HttpConnectionOptions(logging: (LogLevel level, String msg) => _log('[${describeEnum(level)}]: $msg')),
).withAutomaticReconnect().build();

await connection.start();

connection.on('Testing', _handleMessage);

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:

#0 IOClient.send. (package:http/src/io_client.dart:49)
#1 _invokeErrorHandler (dart:async/async_error.dart:45)
#2 _HandleErrorStream._handleError (dart:async/stream_pipe.dart:272)
#3 _ForwardingStreamSubscription._handleError (dart:async/stream_pipe.dart:157)
#4 _HttpClientResponse.listen. (dart:_http/http_impl.dart:712)
#5 _rootRunBinary (dart:async/zone.dart:1378)

This is the log from signalr_core:

[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).

proxy none

merhaba;

String serverUrl = "http://uygulama.cari24.com";
mHubConnection = new HubConnection(serverUrl);

    mHubProxy = mHubConnection.createHubProxy("myhub");

createHubProxy sizde çalışmıyor

reConnection again and again

I used your package in my app.
It is constantly trying to reconnect
I do not want it
I want to try to reconnect when the internet connection is disconnected or Hub Connection stopped..
How do I fix it?
Untitled

complex objects

Hi,
I'm having trouble with a message with the following Schema:

    "deviceId": 37,
    "state": 0,
    "value": "0",
    "values": {
        "autoMemTemp": "21",
        "coldMemTemp": "25",
        "fanDir": "0",
        "fanRate": "A",
        "heatMemTemp": "25",
        "humidity": "0",
        "insideTemperature": "23",
        "mode": "7",
        "outsideTemperature": "18",
        "power": "0",
        "sensorHumidity": "0",
        "temp": "21"
    }
}

my code is basically this:
'
deviceHubConnection.on("status", onReceiveDeviceStatusMessage);
void onReceiveDeviceStatusMessage(List message) {...}
'

The server is returning the value correctly (tried on Angular client), but when I receive the "List message" in flutter, the values property is always null.

Any idea why this happens?

awaiting connection.start() never ends

calling await connection.start() never ends.

flutter doctor -v:

[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.14.6 18G1012, locale en-NO)
    • Flutter version 1.12.13+hotfix.8 at /Developer/flutter
    • Framework revision 0b8abb4724 (6 weeks ago), 2020-02-11 11:44:36 -0800
    • Engine revision e1e6ced81d
    • Dart version 2.7.0

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/sma/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C504
    • CocoaPods version 1.6.0

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 44.0.2
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.43.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.8.1

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

• No issues found!

[Question] Is the code a port of the AspNetCore 3.1 Typescript client codebase?

Before delving into the repo's code for a deeper understanding, if possible, could you tell me how close this codebase is to the official AspNetCore 3.1 Typescript client? Are there missing APIs or behaviours for example?

My reason for asking is back in March I created a fork of another published package (called signalr_client) to support code parity with the 3.1 TS client - this was primarily to have the auto-reconnect feature. I had no response from the package's author in regards to a PR so have been pursuing a possible PR with another developer who has also forked that original package and published their own name (signalr_netcore).

My preference is to use what's already available and if your package already has code parity with the Typescript client I'd be tempted to use yours. I don't want to add to the oversupply of packages if it can be helped.

Cannot start connection with server that requires authentication

I have piece of code:

final hubConnection = HubConnectionBuilder()
.withUrl(
serverUrl,
HttpConnectionOptions(
accessTokenFactory: () => _secureStorage.read(key: 'bearerToken'),
logging: (level, message) => print(message),
))
.build();

await hubConnection.start();

My Hub connection variable always show that _accessTokenFactory is null, that function is never called. I tried creating separate function like:

Future getAccessToken() async{
var token = await _secureStorage.read(key: 'bearerToken');
return token;
}

and calling it like this:

...
accessTokenFactory: () => _getAccessToken(),
...

Putting debug point on "var token..." and it is never called, this function is never executed. Looking deeper into this, the only place that actually uses "accessTokenFactory" is "utils.dart" under "sendMessage" future. Problem is that connection cannot be established with the server without token. I have tested signalr server with simple client in .net and if I provide access token in hubconnection my server works and responds.

Adding a custom header

Is there any way of adding a custom header to the negotiation request? Because the package does not expose the IOClient or BaseClient, therefore I cannot implement it. I'm using another layer of authentication at the server-side via an API key, in addition to the JWT based authentication and I do need to pass that API key to the request headers.

How to Use

Im new to Flutter frameWork
I want to use signalr on flutter to connect to a server and receive notification
below code is how I do it on Java:

        Platform.loadPlatformComponent(new AndroidPlatformComponent());
        Credentials credentials = new Credentials() {
            @Override
             public void prepareRequest(Request request) {
                request.addHeader("username", userId);
            }
        };
        String serverUrl = "http://www.xxxxx.org/";
        mHubConnection = new HubConnection(serverUrl);
        mHubConnection.setCredentials(credentials);
        String SERVER_HUB_CHAT = "notificationHub";
        mHubProxy = mHubConnection.createHubProxy(SERVER_HUB_CHAT);
        ClientTransport clientTransport = new ServerSentEventsTransport(mHubConnection.getLogger());
        SignalRFuture<Void> signalRFuture = mHubConnection.start(clientTransport);

        try {
            signalRFuture.get();
        } catch (Exception ex) {
            UtilFunctions.showToastMessage(getApplicationContext(), ex);
            return;
        }

        String SERVER_METHOD_SEND = "SendNotifications";
        mHubProxy.invoke(SERVER_METHOD_SEND);

        mHubProxy.on("ReceiveNotification", new SubscriptionHandler1<String>() {
            @Override
            public void run(final String string) {
               ......
            }
        }, String.class);

But Im not able to implement on flutter
ppreciate any help.
Thanks in advance.

Wrong condition to create wss url in web_socket_transport.dart

Hi guys, thanks for the lib. It works great on flutter web.
However, I think there is a bug in web_socket_transport.dart.
In line 32 you add access token to url by this condition:
url += (url.contains('?') ? '?' : '&') + "access_token=$encodedToken";
I need to fix this line to get it work:
url += (url.contains('?') ? '&' : '?') + "access_token=$encodedToken";
Please check!

If WSS connection fails the plugin cannot try other transports (SSE and LP)

When I run the following test code
main.txt
I get this error
flutter: SigChar url is https://confidential_link/...
flutter: Starting HubConnection.
flutter: Starting connection with transfer format 'TransferFormat.text'.
flutter: Sending negotiation request: https://confidential_link/...
flutter: Selecting transport 'HttpTransportType.webSockets'.
flutter: (WebSockets transport) Connecting.
flutter: WebSocket connected to wss://confidential_link/...
flutter: The HttpConnection connected successfully.
flutter: Sending handshake request.
flutter: (WebSockets transport) sending data. String data of length '32'.
flutter: Using HubProtocol 'json'.
flutter: (WebSockets transport) socket closed.
flutter: HttpConnection.stopConnection(null) called while in state ConnectionState.disconnecting.
flutter: Connection disconnected with error 'Exception: Server timeout elapsed without receiving a message from the server.'.
flutter: HubConnection.connectionClosed(Exception: Server timeout elapsed without receiving a message from the server.) called while in state HubConnectionState.disconnected.
flutter: Hub handshake failed with error 'Exception: Server timeout elapsed without receiving a message from the server.' during start(). Stopping HubConnection.
flutter: Call to HttpConnection.stop(Exception: Server timeout elapsed without receiving a message from the server.) ignored because the connection is already in the disconnected state.
flutter: HubConnection failed to start successfully because of error '{Exception: Server timeout elapsed without receiving a message from the server..toString}'.
[VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: Exception: Server timeout elapsed without receiving a message from the server.

Our ASP.NET Core application doesn't support WebSockets but it supports Server Sent Events for some reason which I don't know.
Your plugin has a problem to switch from WSS to SSE if it fails to communicate using WSS. When I explicitly specify SSE
logging: (level, message) => print(message), transport: HttpTransportType.serverSentEvents);
then it works fine. The signalr_client 0.1.6 doesn't have this problem and that's the reason I still use it but I want to replace it with your plugin as soon as you resolve this problem. Please go there and see how they made this work.
If you need our URL to test then let me know but you need to disable WSS transport on your server and you'll be fine to reproduce this issue.

Pass parameter

I need to pass Parameter(Not a token but sth like an Id) with HubConnection before _hubConnection.start()
Any help?!

Race Condition with Multiple Stream Methods

I can successfully connect to my server hubs with streaming methods using C# and Typescript clients. However, using this package I get an exception.

Setup

I have two subsequent streaming methods declared:

var messageStream1 = this.connection.stream("serverStreamingMethod1", args: []);
var messageStream2 = this.connection.stream("serverStreamingMethod2", args: []);
  • Logging is also turned on in HttpConnectionOptions.
  • The Flutter device is Web and Android.

Outcome

  • the first call succeeds, messageStream1 is a stream
  • the second call fails, messageStream2 is null
  • the error message "Bad state: Future already completed" is written to the output stream
  • on the server, both the invocations were successfully completed (verified through logging)
  • the signalr client is receiving the messages from both methods (verified though multiple
    "(WebSockets transport) sending data. String data of length 'XXX'." messages with the correct lengths), though the messages aren't being passed to the second stream (as it's null).
  • it makes no difference which order the calls are in

Diagnosis

I've dug/stepped through the code and the error seems to be in http_connection.dart. The Future the error message (Bad state: Future already completed) is complaining about is the _sendBufferedData one returned at the end of the void _bufferData(dynamic data) method (this can be verified by adding a print(_sendBufferedData.isCompleted) statement when using multiple streaming methods. I'm not sure why this is the case (comparing to the TS client code) - but it looks like the buffer is being sent (and that operation not being completed) while other data is being added to the buffer.

Fix

The fix is easy... adding a guard around the _sendBufferedData.complete(); call in the _bufferData method fixes the issue, ie:

if(!_sendBufferedData.isCompleted) {
      _sendBufferedData.complete();
}

...this makes general sense as it means that the _buffer actually buffers data until the last buffered contents have been send successfully in the send loop. I'm not sure why that guard isn't in the TS client, though it seems to work without it...

I've tested this via Flutter Web and Android and it seems to work.

If you're open to a pull request, I can do that.

Try to connect to server and get exception on call start();

I try to open connect to server and on start get exception:

** {Exception: WebSocket closed with status code: 1002 (null).**

What am I doing wrong?

My code:

final connection = HubConnectionBuilder().withUrl(URL+'/ws/geo',
          HttpConnectionOptions(
            client: IOClient(HttpClient()..badCertificateCallback = (x, y, z) => true),
            logging: (level, message) => print('$level: $message'),
            accessTokenFactory: getToken,
          )).withAutomaticReconnect().build();
await connection.start();

Logs:
LogLevel.debug: Starting HubConnection. LogLevel.debug: Starting connection with transfer format 'TransferFormat.text'. LogLevel.debug: Sending negotiation request: https://ultapps.com/ws/geo/negotiate. LogLevel.debug: Selecting transport 'HttpTransportType.webSockets'. LogLevel.trace: (WebSockets transport) Connecting. LogLevel.information: WebSocket connected to wss://ultapps.com/ws/geo?id=-q9VeFkVBznJZKVRHg-o2g&access_token=<token>. LogLevel.debug: The HttpConnection connected successfully. LogLevel.debug: Sending handshake request. LogLevel.trace: (WebSockets transport) sending data. String data of length '32'. LogLevel.information: Using HubProtocol 'json'. LogLevel.trace: (WebSockets transport) socket closed. LogLevel.debug: HttpConnection.stopConnection(Exception: WebSocket closed with status code: 1002 (null).) called while in state ConnectionState.connected. LogLevel.error: Connection disconnected with error 'Exception: WebSocket closed with status code: 1002 (null).'. LogLevel.debug: HubConnection.connectionClosed(Exception: WebSocket closed with status code: 1002 (null).) called while in state HubConnectionState.disconnected. LogLevel.debug: HttpConnection.stopConnection(null) called while in state ConnectionState.disconnected. LogLevel.debug: Call to HttpConnection.stopConnection(null) was ignored because the connection is already in the disconnected state. LogLevel.debug: Hub handshake failed with error 'Exception: WebSocket closed with status code: 1002 (null).' during start(). Stopping HubConnection. LogLevel.debug: Call to HttpConnection.stop(Exception: WebSocket closed with status code: 1002 (null).) ignored because the connection is already in the disconnected state. LogLevel.debug: HubConnection failed to start successfully because of error '{Exception: WebSocket closed with status code: 1002 (null)..toString}'.

Exception: Starting connection with transfer format 'TransferFormat.text'.

{Error info}_20200605140836

code:

class HomeState extends State<MyHomePage> {
  StringBuffer remoteMsg = StringBuffer();
  HubConnection hubConnection = HubConnectionBuilder().withUrl('http://xxx.xxx/:8000/api/chatHub',
      HttpConnectionOptions(
        transport:HttpTransportType.none,
        logging: (level, message) => print("message: $message"),
        accessTokenFactory:() => Future.value("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiYWRtaW4iLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6ImFkbWluIiwianRpIjoiMSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvZXhwaXJhdGlvbiI6IjYvNS8yMCAyOjQwOjMzIFBNIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiQWRtaW4iLCJuYmYiOjE1OTEzMzU2MzMsImV4cCI6MTU5MTMzOTIzMywiaXNzIjoiT0EuUlNJLkJhY2tlbmQiLCJhdWQiOiJ3ciJ9.gKaIBDSF0MLJ5b6j7iiWKCeVvQJPMkqYJOuwPW_Yncw")
      )).build();

  @override
  void initState(){
    super.initState();
    init();
  }

  init() async {
    hubConnection.on('ReceiveMessage', (message) {
      setState(() {
        message.forEach((v) => remoteMsg.write(v));
        print(message.toString());
      });
    });
    try{
      await hubConnection.start();
      print("连接成功...");
    }catch(e){
      print("连接失败...");
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Text("message from server: ${remoteMsg.toString()}"),
          TextField(
            decoration:InputDecoration(
              hintText:"Enter some text",
            ),
            onSubmitted:((v)async => await hubConnection.invoke('SendMessage', args: ['Flutter', v])),
          ),
        ],
      ),
    );
  }
}

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

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.

Add documentation

I think some more details on how to use this package would be highly appreciated.

Passing data on connection

Hi, you have TODO in code:
static String _createConnectUrl(String url, String connectionToken) { if (connectionToken == null) { return url; } // TODO: Look at this... return url + '?' + 'id=$connectionToken'; //return url + (url.contains('?') ? '?' : '&') + 'id=$connectionToken'; }

And my question is do you plan change this TODO? because in this case is difficult pass data.
When i set in url for example "https://test.com/Hub?userId=24" i get in server this one "https://test.com/Hub?userId=24?id=connectionToken"

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

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

Adding a custom header (CERTIFICATE_VERIFY_FAILED)

I added a header referring to this article. However, a CERTIFICATE_VERIFY_FAILED error occurs.

E/flutter (11646): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: HandshakeException: Handshake error in client (OS Error: 
E/flutter (11646): 	CERTIFICATE_VERIFY_FAILED: self signed certificate(handshake.cc:354))

An error occurs.
I have referred to this article but it has not been resolved. Am I doing something wrong?
I'd appreciate it if you could tell me how.

Exception: The underlying connection was closed before the hub handshake could complete.

Hi, tnx for package!

I'm getting this error while trying to connect to hub that's deployed to azure running emulator.
`final connection = HubConnectionBuilder()
.withUrl(
'https://fortestpurpose.azurewebsites.net/hub',
HttpConnectionOptions(
transport: HttpTransportType.webSockets,
logging: (level, message) => print(message),
))
.withAutomaticReconnect()
.build();

await connection.start();`

Using localhost service there is no such error for example with url:
http://10.0.2.2:5000/hub

Any clues why this can happen?

Exception has occurred. StateError (Bad state: Future already completed)

Hello, I keep getting a similar error to this any help?
These are the error logs...
I/flutter (14832): Starting HubConnection.
I/flutter (14832): Starting connection with transfer format 'TransferFormat.text'.
I/flutter (14832): (WebSockets transport) Connecting.
I/flutter (14832): WebSocket connected to ws:// removed for privacy reasons
I/flutter (14832): The HttpConnection connected successfully.
I/flutter (14832): Sending handshake request.
I/flutter (14832): (WebSockets transport) socket closed.
I/flutter (14832): HttpConnection.stopConnection(Exception: WebSocket closed with status code: 1002 (null).) called while in state ConnectionState.connected.
I/flutter (14832): Connection disconnected with error 'Exception: WebSocket closed with status code: 1002 (null).'.
E/flutter (14832): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Bad state: Future already completed
E/flutter (14832): #0 _AsyncCompleter.complete (dart:async/future_impl.dart:45:31)
E/flutter (14832): #1 TransportSendQueue.stop
package:signalr_core/src/http_connection.dart:655
E/flutter (14832): #2 HttpConnection._stopConnection
package:signalr_core/src/http_connection.dart:291
E/flutter (14832): #3 HttpConnection._startTransport.
package:signalr_core/src/http_connection.dart:457
E/flutter (14832): #4 WebSocketTransport._close
package:signalr_core/…/transports/web_socket_transport.dart:130
E/flutter (14832): #5 WebSocketTransport.connect.
package:signalr_core/…/transports/web_socket_transport.dart:85
E/flutter (14832): #6 _rootRun (dart:async/zone.dart:1346:47)
E/flutter (14832): #7 _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (14832): #8 _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (14832): #9 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:394:13)
E/flutter (14832): #10 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:404:15)
E/flutter (14832): #11 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
E/flutter (14832): #12 _ForwardingStream._handleDone (dart:async/stream_pipe.dart:99:10)
E/flutter (14832): #13 _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:161:13)
E/flutter (14832): #14 _rootRun (dart:async/zone.dart:1346:47)
E/flutter (14832): #15 _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (14832): #16 _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (14832): #17 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:394:13)
E/flutter (14832): #18 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:404:15)
E/flutter (14832): #19 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
E/flutter (14832): #20 _SyncStreamControllerDispatch._sendDone (dart:async/stream_controller.dart:741:19)
E/flutter (14832): #21 _StreamController._closeUnchecked (dart:async/stream_controller.dart:596:7)
E/flutter (14832): #22 _StreamController.close (dart:async/stream_controller.dart:589:5)
E/flutter (14832): #23 new _WebSocketImpl._fromSocket. (dart:_http/websocket_impl.dart:1157:19)
E/flutter (14832): #24 _rootRunBinary (dart:async/zone.dart:1378:47)
E/flutter (14832): #25 _CustomZone.runBinary (dart:async/zone.dart:1272:19)
E/flutter (14832): #26 _CustomZone.runBinaryGuarded (dart:async/zone.dart:1178:7)
E/flutter (14832): #27 _BufferingStreamSubscription._sendError.sendError (dart:async/stream_impl.dart:360:15)
E/flutter (14832): #28 _BufferingStreamSubscription._sendError (dart:async/stream_impl.dart:375:18)
E/flutter (14832): #29 _BufferingStreamSubscription._addError (dart:async/stream_impl.dart:280:7)
E/flutter (14832): #30 _SinkTransformerStreamSubscription._addError (dart:async/stream_transformers.dart:75:11)
E/flutter (14832): #31 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:113:7)
E/flutter (14832): #32 _HttpDetachedStreamSubscription._maybeScheduleData. (dart:_http/http_parser.dart:178:20)
E/flutter (14832): #33 _rootRun (dart:async/zone.dart:1346:47)
E/flutter (14832): #33 _rootRun (dart:async/zone.dart:1346:47)
E/flutter (14832): #34 _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (14832): #35 _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (14832): #36 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1202:23)
E/flutter (14832): #37 _rootRun (dart:async/zone.dart:1354:13)
E/flutter (14832): #38 _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (14832): #39 _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (14832): #40 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1202:23)
E/flutter (14832): #41 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter (14832): #42 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
E/flutter (14832):
I/flutter (14832): Hub handshake failed with error 'Exception: Connection stopped.' during start(). Stopping HubConnection.
I/flutter (14832): HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.
I/flutter (14832): HttpConnection.stopConnection(null) called while in state ConnectionState.disconnecting.
I/flutter (14832): Connection disconnected with error 'Exception: Connection stopped.'.
I/flutter (14832): HubConnection failed to start successfully because of error '{Bad state: Future already completed.toString()}'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.