shaqian / flutter_ssh

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

App crashes when connecting #10

Closed nn1ks closed 5 years ago

nn1ks commented 5 years ago

When using the .connect() method the app crashes and throws the following error:

FATAL EXCEPTION: Thread-5
E/AndroidRuntime( 1722): Process: com.niklas8.remotefiles, PID: 1722
E/AndroidRuntime( 1722): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: Thread-5
E/AndroidRuntime( 1722):        at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:794)
E/AndroidRuntime( 1722):        at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(FlutterJNI.java:727)
E/AndroidRuntime( 1722):        at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:140)
E/AndroidRuntime( 1722):        at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:230)
E/AndroidRuntime( 1722):        at sq.flutter.ssh.SshPlugin$1.run(SshPlugin.java:169)
E/AndroidRuntime( 1722):        at java.lang.Thread.run(Thread.java:762)

This occurred since I updated to Flutter 1.7 On iOS everything is working

conorthedev commented 5 years ago

Getting this too :/

mix1009 commented 5 years ago

Here is a fix: https://github.com/shaqian/flutter_ssh/commit/fcee36885760b042a55d28de4339deea076da69d

SunLongbri commented 5 years ago

I also have this problem,how do I should to do ? I need a help.

shaqian commented 5 years ago

Thanks @mix1009! I added the fix in v0.0.4. Please have a try.

sjagat commented 5 years ago

Thanks @mix1009! I added the fix in v0.0.4. Please have a try.

I tried version 0.0.4 and still noticed the same issue

frjonsen commented 5 years ago

Getting this as well when attempting to start a shell. It also seems that the error handling is throwing a nested error.

D/SshPlugin(11675): Session connected E/SshPlugin(11675): Error starting shell: Methods marked with @UiThread must be executed on the main thread. Current thread: Thread-23 D/AndroidRuntime(11675): Shutting down VM E/AndroidRuntime(11675): FATAL EXCEPTION: main E/AndroidRuntime(11675): Process: se.jonsen.unarchive_android, PID: 11675 E/AndroidRuntime(11675): java.lang.IllegalStateException: Reply already submitted E/AndroidRuntime(11675): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:135) E/AndroidRuntime(11675): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:230) E/AndroidRuntime(11675): at sq.flutter.ssh.SshPlugin$MethodResultWrapper$2.run(SshPlugin.java:81) E/AndroidRuntime(11675): at android.os.Handler.handleCallback(Handler.java:873) E/AndroidRuntime(11675): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(11675): at android.os.Looper.loop(Looper.java:193) E/AndroidRuntime(11675): at android.app.ActivityThread.main(ActivityThread.java:6898) E/AndroidRuntime(11675): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(11675): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537) E/AndroidRuntime(11675): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Nico04 commented 5 years ago

I've got a similar issue when connecting to sftp.

First it break on exception : PlatformException(unknown_client, Unknown client, null) at line 569 of decodeEnvelope() of message_codecs.dart

And right after app crashes :

13:48:09.814 18 info flutter.tools I/flutter (29029): PlatformException(unknown_client, Unknown client, null)
13:48:09.824 19 info flutter.tools E/AndroidRuntime(29029): FATAL EXCEPTION: Thread-3
13:48:09.824 21 info flutter.tools E/AndroidRuntime(29029): java.lang.NullPointerException: Attempt to read from field 'com.jcraft.jsch.ChannelSftp sq.flutter.ssh.SshPlugin$SSHClient._sftpSession' on a null object reference
13:48:09.824 22 info flutter.tools E/AndroidRuntime(29029):     at sq.flutter.ssh.SshPlugin$14.run(SshPlugin.java:519)
13:48:09.825 23 info flutter.tools E/AndroidRuntime(29029):     at java.lang.Thread.run(Thread.java:764)

plugin v0.0.4, Flutter v1.9.1

Nico04 commented 5 years ago

I've got a similar issue when connecting to sftp.

First it break on exception : PlatformException(unknown_client, Unknown client, null) at line 569 of decodeEnvelope() of message_codecs.dart

And right after app crashes :

13:48:09.814 18 info flutter.tools I/flutter (29029): PlatformException(unknown_client, Unknown client, null)
13:48:09.824 19 info flutter.tools E/AndroidRuntime(29029): FATAL EXCEPTION: Thread-3
13:48:09.824 21 info flutter.tools E/AndroidRuntime(29029): java.lang.NullPointerException: Attempt to read from field 'com.jcraft.jsch.ChannelSftp sq.flutter.ssh.SshPlugin$SSHClient._sftpSession' on a null object reference
13:48:09.824 22 info flutter.tools E/AndroidRuntime(29029):   at sq.flutter.ssh.SshPlugin$14.run(SshPlugin.java:519)
13:48:09.825 23 info flutter.tools E/AndroidRuntime(29029):   at java.lang.Thread.run(Thread.java:764)

plugin v0.0.4, Flutter v1.9.1

I found out that I need to call client.connect() before client.connectSFTP(). Now it works

shaqian commented 5 years ago

This is fixed 0.0.5. Archiving the issue.

Thanks, Qian

omarwaleed commented 4 years ago

Hey @shaqian , I have the same issue as @Nico04 even after upgrading to version 0.0.5 It throws an error whenever it tries to connect on sftp client thanks

carlhung commented 3 years ago

i still got the same error: E/AndroidRuntime( 7667): FATAL EXCEPTION: Thread-5 E/AndroidRuntime( 7667): Process: com.example.online_disk, PID: 7667 E/AndroidRuntime( 7667): java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Vector com.jcraft.jsch.ChannelSftp.ls(java.lang.String)' on a null object reference E/AndroidRuntime( 7667): at sq.flutter.ssh.SshPlugin$8.run(SshPlugin.java:433) E/AndroidRuntime( 7667): at java.lang.Thread.run(Thread.java:923) I/Process ( 7667): Sending signal. PID: 7667 SIG: 9 Lost connection to device.

i did call client.connect() before client.connectSFTP()

when trying calling client.sftpLs("/"), it crashes.

my system config is: Flutter 1.24.0-8.0.pre.373 • channel master • https://github.com/flutter/flutter.git Framework • revision 8de72126e9 (8 hours ago) • 2020-11-26 07:48:03 +0800 Engine • revision 20caf54969 Tools • Dart 2.12.0 (build 2.12.0-76.0.dev)