jamiewest / signalr_core

ASP.NET Core SignalR Dart Client
https://pub.dev/packages/signalr_core
MIT License
90 stars 58 forks source link

InvalidOperationException: Sequence contains no matching element #110

Closed learntheropes closed 6 months ago

learntheropes commented 6 months ago
import 'dart:io';
import 'package:http/io_client.dart';
import 'package:signalr_core/signalr_core.dart';
import 'variables.dart';

Future<void> main(List<String> arguments) async {
  final connection = HubConnectionBuilder()
      .withUrl(
          'https://publicapi.sandbox.hercle.financial/ExecutionLiveServer/v1',
          HttpConnectionOptions(
            accessTokenFactory: () async {
              return Env.hercleApikey;
            },
            client: IOClient(
                HttpClient()..badCertificateCallback = (x, y, z) => true),
            logging: (level, message) => print(message),
          ))
      // .withAutomaticReconnect()
      .build();

  await connection.start();

  connection.on('executionEvents', (message) {
    print('Message $message');
  });

  await connection.invoke('GetPairs', args: ['0123456789']);
}

I get:

Building package executable... 
Built signalr:signalr.
Starting HubConnection.
Starting connection with transfer format 'TransferFormat.text'.
Sending negotiation request: https://publicapi.sandbox.hercle.financial/ExecutionLiveServer/v1/negotiate.
Selecting transport 'HttpTransportType.webSockets'.
(WebSockets transport) Connecting.
WebSocket connected to wss://publicapi.sandbox.hercle.financial/ExecutionLiveServer/v1?id=kgD5bYRbST6O-cKYfkUf0Q&access_token=<token_omitted>
The HttpConnection connected successfully.
Sending handshake request.
(WebSockets transport) sending data. String data of length '32'.
Using HubProtocol 'json'.
(WebSockets transport) data received. String data of length '3'
Server handshake complete.
HubConnection connected successfully.
(WebSockets transport) sending data. String data of length '92'.
(WebSockets transport) data received. String data of length '119'
Close message received from server.
Stopping HubConnection
(WebSockets transport) socket closed.
HttpConnection.stopConnection(null) called while in state ConnectionState.disconnecting.
Connection disconnected with error 'Exception: Server returned an error on close: Connection closed with an error. InvalidOperationException: Sequence contains no matching element'.
HubConnection.connectionClosed(Exception: Server returned an error on close: Connection closed with an error. InvalidOperationException: Sequence contains no matching element) called while in state HubConnectionState.disconnecting.
Unhandled exception:
Exception: Server returned an error on close: Connection closed with an error. InvalidOperationException: Sequence contains no matching element

What could be the issue?

Repo: https://github.com/learntheropes/signalr

learntheropes commented 6 months ago

Resolved. Not related to the package.