diff --git a/lib/connector/meshcore_connector_tcp.dart b/lib/connector/meshcore_connector_tcp.dart index 01c2b92..92b98d7 100644 --- a/lib/connector/meshcore_connector_tcp.dart +++ b/lib/connector/meshcore_connector_tcp.dart @@ -22,9 +22,6 @@ class MeshCoreTcpManager { } Future disconnect() async { - if (!_service.isConnected && _service.activeEndpoint == null) { - return; - } _debugLog?.info('TcpManager.disconnect', tag: 'TCP'); await _service.disconnect(); } diff --git a/lib/services/tcp_transport_service_native.dart b/lib/services/tcp_transport_service_native.dart index d8a3ab3..a6db99b 100644 --- a/lib/services/tcp_transport_service_native.dart +++ b/lib/services/tcp_transport_service_native.dart @@ -175,6 +175,11 @@ class TcpTransportService { } void _handleSocketDone() { + if (_status == TcpTransportStatus.disconnecting || + _status == TcpTransportStatus.disconnected) { + return; + } + _addFrameError(StateError('TCP socket closed by remote endpoint')); unawaited(disconnect()); }