Android Question freeze during downloading with SFTP/JSCH

Quandalle

Member
Licensed User
I use the sftp/JSCH library (see https://www.b4x.com/android/forum/threads/android-sftp-based-on-jsch-tutorial.26994/#content) to exchange files of several MB with a sftp server.

I have no authentication problems, and the transfer normally starts after a call to sftp.downloadfile.

The problem occurs during data reception. Sometimes the file loads completely, but very often it freezes during the download without any error, event or timeout. I use the events sftp_DownloadCompleted, sftp_ShowMessage, sftp_DownloadProgress)

The time of freezing is never the same, sometimes at the beginning, sometimes further away. Sometimes the freeze also occurs for 5 or 10 or 20 seconds and it continues for a few hundred additional bytes before locking again.

During a freeze, if I restart the transfer without leaving the application sometimes it happens, sometimes it freezes in another place.

The server I'm exchanging with has no problem, for example during a freeze if I use on the same android phone an transfer application managing the sftp ( AndFTP) to load my file it goes well and moreover with a higher speed than my Android application. Similarly, a Filezilla from a Windows PC works without any problems.

I have of course tried application both in Debug mode, and in release mode, on several phones and versions of Android, and also by putting my code either in an activity or in a service, etc... but the problem occurs exactly the same way.


Are there any "hidden" parameters in JSCH that would allow you to unlock or find out more, where is there another library that manages the sftp


Thank you for your help

My code
B4X:
Sub DownloadFile
    sftp.Initialize("sftp", "xxxxx", « xxxxx », "xxx", 22)
    sftp.DownloadFile("file", "dataPath","path")
End Sub

Sub sftp_DownloadProgress (ServerPath As String, TotalDownloaded As Long, Total As Long)
    lblCount.Text = TotalDownloaded
    lblCount2.Text = lblCount2.Text +1
End Sub

Sub sftp_DownloadCompleted (ServerPath As String, Success As Boolean)
            If Success Then
                Log("dl sucess")
            Else
                Log ("dl erreur")
            End If
End Sub

Sub sftp_PromptYesNo (Message As String)
    Log("Prompt YesNo " & Message)
    sftp.SetPromptResult(True)
End Sub

Sub sftp_ShowMessage (Message As String)
    Log("Show Message : " & Message)
End Sub
 
Last edited:

Quandalle

Member
Licensed User
Yes Freeze mean downloas never complete and the completed event not raised.

I have activated the "unfiltered trace", it slows down downloading considerably, because DownnloadProgress events are frequently generated with small data blocks,

I didn't find any specific message for "JSCH"

on the other hand it seemed to me (without being sure) to see slowdowns of a few seconds at the time of a message linked to traces of wifi:
"[check_file_size:402]/data/hwlogdir/wifi_log/wifi_log_1 log file beyond size=10240Byte, creat new file
[rename_old_file:107]rename_old_file "

Finally I reinstalled the jar jsch, and for the moment I did seem no freeze or slowdown

Anyway, thank you for the answer, as a new developer on the B4X environment, I hadn't paid attention to that little box "unfiltered trace" that is in front of me, at least I learned something :)
 
Upvote 0
Top