TerminalStudio / dartssh2

SSH and SFTP client written in pure Dart, aiming to be feature-rich as well as easy to use.
https://pub.dev/packages/dartssh2
MIT License
216 stars 58 forks source link

bug: Unhandled Exception: SSHStateError(Transport is closed) #86

Open diybl opened 1 year ago

diybl commented 1 year ago

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 commented 1 year ago

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.

DevAloshe commented 1 year ago

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