Closed joeyyy688 closed 2 years ago
@joeyyy688 have you find a solution?
I have
signalr_core: ^1.1.1
in my pubspec.yaml file and I'm getting the same error but from another place in the code
Bad state: Future already completed
#0 _AsyncCompleter.complete (dart:async/future_impl.dart:45:31)
#1 HubConnection._processHandshakeResponse (package:signalr_core/src/hub_connection.dart:778:25)
#2 HubConnection._processIncomingData (package:signalr_core/src/hub_connection.dart:682:14)
#3 ServerSentEventsTransport.connect.<anonymous closure> (package:signalr_core/src/transports/server_sent_events_transport.dart:80:17)
#4 _rootRunUnary (dart:async/zone.dart:1436:47)
#5 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#6 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#7 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#8 _DelayedData.perform (dart:async/stream_impl.dart:591:14)
#9 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:706:11)
#10 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:663:7)
#11 _rootRun (dart:async/zone.dart:1420:47)\n#12 ...
It fails on statement
_handshakeCompleter.complete();
in the _processHandshakeResponse function. You have already fixed in as
if (!_handshakeCompleter.isCompleted) {
_handshakeCompleter.complete();
}
but in _connectionClosed function. I think you just need to do the same thing in _processHandshakeResponse. Can you please fix it soon?
@misici234 I haven't tried it again since I faced this error, once you've found the solution I've closed this issue. Thank you
@joeyyy688 why did you close this issue when it's not resolved? Please reopen it.
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()}'.