shaqian / flutter_ssh

SSH and SFTP client for Flutter
https://pub.dartlang.org/packages/ssh
MIT License
117 stars 83 forks source link

iOS startShell crashes the app #24

Open michcio53 opened 4 years ago

michcio53 commented 4 years ago

The code I have literally copy-pasted from example. I have tested this library on real device and when there is client.startShell in code, then whole app is crashing. This bug does not exist on Simulator. Any tips how to solve it?

 var client = new SSHClient(
      host: controlServer.host,
      port: 22,
      username: controlServer.login,
      passwordOrKey: controlServer.password);
      String result = await client.connect();
      try {
      String result = await client.connect();
      if (result == "session_connected") {
        result = await client.startShell(
            ptyType: "xterm",
            callback: (dynamic res) {

            });

        if (result == "shell_started") {
          print(await client.writeToShell("echo hello > world\n"));
          print(await client.writeToShell("cat world\n"));
          new Future.delayed(
            const Duration(seconds: 5),
            () async => await client.closeShell(),
          );
        }
      }
    } catch (PlatformException){
      print('Error: ${}\nError Message: e}');
    }
thomashuettmaier commented 4 years ago

Same error on Android with client.connect() , app starts fine but when starting the SSH connection the app crashed. On emulator everything is fine.

thomashuettmaier commented 4 years ago

This is the error I get:

2019-12-16 14:09:10.421 11233-11415/com.baumaster.statistics E/SshPlugin: Connection failed: java.lang.ClassNotFoundException: com.jcraft.jsch.jce.Random 2019-12-16 14:09:10.425 11233-11417/com.baumaster.statistics E/AndroidRuntime: FATAL EXCEPTION: Thread-5 Process: com.baumaster.statistics, PID: 11233 java.lang.NullPointerException: Attempt to read from field 'b.a.a.h e.a.a.a$q.e' on a null object reference at e.a.a.a$e.run(:559) at java.lang.Thread.run(Thread.java:919)

thomashuettmaier commented 4 years ago
IsaBass commented 4 years ago

I also have the same problem, but crashes in the emulator and the physical mobile in debug mode. No error message. Just do nothing after client.connect () On Android.

shaqian commented 4 years ago

I also have the same problem, but crashes in the emulator and the physical mobile in debug mode. No error message. Just do nothing after client.connect () On Android.

@IsaBass, are you using Flutter 1.12? I see others reporting similar issue here: https://github.com/shaqian/flutter_ssh/issues/28

Does it work if you downgrade Flutter version?

Thanks, Qian

tc14077 commented 4 years ago

I also have the same problem, but crashes in the emulator and the physical mobile in debug mode. No error message. Just do nothing after client.connect () On Android.

@IsaBass, are you using Flutter 1.12? I see others reporting similar issue here: #28

Does it work if you downgrade Flutter version?

Thanks, Qian

Hi Qian,

We are all encountering same issue after upgrading to Flutter 1.12. See the issue: #27

I have no choice but downgraded my flutter version in order to use this plugin.

Any suggestions or updates will provide in future? Thanks, Tom

shaqian commented 4 years ago

27

@tc14077, this seems to be a viable solution. Can you please have a try? https://github.com/shaqian/flutter_ssh/issues/27#issuecomment-599180850

Thanks, Qian

tc14077 commented 4 years ago

27

@tc14077, this seems to be a viable solution. Can you please have a try? #27 (comment)

Thanks, Qian

Hi @shaqian ,

I followed the suggestion on #27, the build can be done. However, there is another problem happened and the symptom is similar to #37. Perhaps you can give some advice to me. FYI, I am using flutter version v1.12.13+hotfix.9.

Thanks, Tom

EDIT: I think I have fix the problem, please see here