I'm downloading a number of png's and have experienced this:
When I don't use "persistConnection" it goes fast, but requires as many connection pr. account as the number of files !
Using "persistConnection" there is a delay at about 30 seconds between each file.
(Nearly) same code in B4A is as fast as not "persistConnection" in B4i.
Comments on code: the files to download is found in a database (DBResult) and is saved in a KeyValueStore (kvs) for later use.
Attached: Application-logs & FTP-server-log (csv)
When I don't use "persistConnection" it goes fast, but requires as many connection pr. account as the number of files !
Using "persistConnection" there is a delay at about 30 seconds between each file.
(Nearly) same code in B4A is as fast as not "persistConnection" in B4i.
Comments on code: the files to download is found in a database (DBResult) and is saved in a KeyValueStore (kvs) for later use.
B4X:
Sub process_getallmain(result As DBResult)
Dim but As String
Dim background As String
Dim link As String
pendingDownloadCount = 0
ftpService.Initialize("FTP",serverIP,21,"apps","apps")
Dim no As NativeObject = ftpService
no.GetField("server").SetField("persistConnection", True)
For Each records() As Object In result.Rows
but=records(result.Columns.Get("button"))
background = records(result.Columns.Get("background"))
link = records(result.Columns.Get("link"))
kvs.PutSimple(but & "_background", background)
kvs.PutSimple(but & "_link", link)
ftpList.Add(background)
pendingDownloadCount = pendingDownloadCount +1
Next
getButtonImage(ftpList.Get(pendingDownloadCount - 1))
End Sub
Sub getButtonImage(background As String)
ftpService.DownloadFile("/apps/1/" & background,False,File.DirLibrary, background)
End Sub
Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
If Success Then
Log(ServerPath & " - OK")
pendingDownloadCount = pendingDownloadCount - 1
If pendingDownloadCount = 0 Then
PrepareAll
hd.ProgressDialogHide
Else
getButtonImage(ftpList.Get(pendingDownloadCount - 1))
End If
Else
Log(ServerPath & " - " & LastException.Description)
getButtonImage(ftpList.Get(pendingDownloadCount - 1))
End If
End Sub
Attached: Application-logs & FTP-server-log (csv)