dartssh2 icon indicating copy to clipboard operation
dartssh2 copied to clipboard

bug: Unhandled Exception: SSHStateError(Transport is closed)

Open diybl opened this issue 2 years ago • 2 comments

when the remote reboot or shutdown

the done handler not working. `await session.done;

client.close();
await client.done;`

the error is.

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: SSHStateError(Transport is closed) #0 SSHTransport.sendPacket (package:dartssh2/src/ssh_transport.dart:183:7) #1 SSHClient._sendMessage (package:dartssh2/src/ssh_client.dart:480:16) #2 SSHChannelController._sendEOFIfNeeded (package:dartssh2/src/ssh_channel.dart:264:16) #3 SSHChannelController.close (package:dartssh2/src/ssh_channel.dart:195:5) #4 SSHClient._closeChannels (package:dartssh2/src/ssh_client.dart:447:15) #5 SSHClient._handleTransportClosed (package:dartssh2/src/ssh_client.dart:467:5) #6 new SSHClient. (package:dartssh2/src/ssh_client.dart:166:14)

diybl avatar Aug 14 '23 15:08 diybl

void sendPacket(Uint8List data) { if (isClosed) { return; throw SSHStateError('Transport is closed'); }

i add return before throw SSHStateError('Transport is closed'); and then temporary solve.

diybl avatar Aug 14 '23 17:08 diybl

I have the same error except the error occurs when I connect to my Cisco catalyst switch 2960 serires in the first run I get the result then when using the same client one more time to excute the same command it says :

SSHStateError(Transport is closed)

My Code :

static cisco(SSHClient client) async {
    await client.ping();
    print(await client.run('show env fan'));
    await client.ping();

}

BTW : the same code runs on all other devices very well

DevAloshe avatar Oct 04 '23 10:10 DevAloshe