Hi everybody!
I have a problem with FTP upload and download. It`s work fine only in WiFi. When I disable Wifi on my phone, application returns error. First time return message "SocketException: connection timed out", another time return " broken pipe " or " connection closed without indication "
I thought that the error in active / passive mode, but I also use passive mode
When I'm connected through a B4A bridge, always works perfect.
I use android 2.2 on Samsung phone GT I5500
Where could be the error?
I have a problem with FTP upload and download. It`s work fine only in WiFi. When I disable Wifi on my phone, application returns error. First time return message "SocketException: connection timed out", another time return " broken pipe " or " connection closed without indication "
I thought that the error in active / passive mode, but I also use passive mode
When I'm connected through a B4A bridge, always works perfect.
I use android 2.2 on Samsung phone GT I5500
Where could be the error?
B4X:
Sub Process_Globals
End Sub
Sub Globals
Dim FTP As FTP
End Sub
Sub Activity_Create(FirstTime As Boolean)
'FTP.Initialize("FTP", "ftp.malovrh4.freeweb.siol.net", 21, "malovrh4", "")
FTP.Initialize("FTP", "ftp.malovrh4.freeweb.siol.net", 21, "malovrh4", "*******")
FTP.PassiveMode =True
activity.AddMenuItem ("Download","menu")
activity.AddMenuItem ("Upload","menu")
End Sub
Sub Menu_Click
Select Sender
Case ("Download")
download
Case("Upload")
upload
End Select
End Sub
Sub download
FTP.DownloadFile ("/elektro/RLDcsv.csv" , False , File.DirDefaultExternal , "RLDcsv.csv")
End Sub
Sub upload
FTP.UploadFile(File.DirDefaultExternal, "RLDcsv.csv", True, "/elektro/RLDcsv.csv")
End Sub
Sub FTP_UploadProgress (ServerPath As String, TotalUploaded As Long, Total As Long)
Dim s As String
s = "Uploaded " & Round(TotalUploaded / 1000) & "KB"
If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
End Sub
Sub FTP_UploadCompleted (ServerPath As String, Success As Boolean)
Log(ServerPath & ", Success=" & Success)
If Success=True Then ToastMessageShow("Data send on Server",False)
If Success=False Then Msgbox("E R R O R" & CRLF & "try again" ,"refresh")
If Success=False Then Log("Podatki N I S O poslani na strežnik, poskusi ponovno")
If Success=False Then Msgbox ("lastexception: " & LastException.Message,"")
If Success=False Then Log ("lastexception: " & LastException.Message)
End Sub
Sub FTP_DownloadProgress (ServerPath As String, TotalDownloaded As Long, Total As Long)
Dim s As String
Log ("totaldownload: " & TotalDownloaded)
Log ("total: " & Total)
s = "Downloaded " & Round(TotalDownloaded / 1000) & "KB"
If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
Log(s)
End Sub
Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
If Success=True Then ToastMessageShow("Data saved on SD Card",False)
If Success=False Then Msgbox("E R R O R" & CRLF & "try again" ,"refresh")
If Success=False Then Msgbox("LastException: " & LastException.Message,"")
If Success=False Then Log ("Podatki N I S O prejeti na SD spomin" & CRLF & "poskusi ponovno")
If Success=False Then Log(LastException.Message)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub