FTP works only in WIFi mode

malci

Member
Licensed User
Longtime User
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?

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
 

Attachments

  • FTP_test.zip
    5.9 KB · Views: 191

Erel

B4X founder
Staff member
Licensed User
Longtime User
Instead of:
B4X:
    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)
You should write:
B4X:
If Success = True Then
 ToastMessageShow("Data saved on SD Card",False)
Else
 Msgbox("E R R O R" & CRLF & "try again" ,"refresh")
 Msgbox("LastException: " & LastException.Message,"")
 Log ("Podatki N I S O prejeti na SD spomin" & CRLF & "poskusi ponovno")
 Log(LastException.Message)
End If


The problem is most likely with your mobile ISP which can block ports other than 80 (HTTP port).
 
Upvote 0

malci

Member
Licensed User
Longtime User
Thanks for the quick reply.

I called technical support my mobile ISP ...
if I have understood correctly, he has an open port 20, but port 21 are blocked for security reasons .... :mad:

If I enter my FTP address (ftp.freeweb.siol.net/malovrh4/elektro/RLDcsv.csv) in internet browser, the file opens, but in the application does not work

Do you have any advice on how to save the data to the server without FTP?


by, malci
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Thanks for the quick reply.

I called technical support my mobile ISP ...
if I have understood correctly, he has an open port 20, but port 21 are blocked for security reasons .... :mad:

If I enter my FTP address (ftp.freeweb.siol.net/malovrh4/elektro/RLDcsv.csv) in internet browser, the file opens, but in the application does not work

Do you have any advice on how to save the data to the server without FTP?


by, malci

Why not trying to ftp at port 20 as adviced by you ISP?
 
Upvote 0

malci

Member
Licensed User
Longtime User
bg1992, thanks for the help

In your examples I managed to find a bug. My FTP server does not support access with the mobile phone.
I do not know why, but when I changed FTP server with free "http://www.serversfree.com/" works perfectly in both mode (WiFi or mobile)

Thank you again

bye, malci
 
Upvote 0

maso1975

Member
Licensed User
Longtime User
Hello everyone,

my something similar happened to me with my ftp connection, from the beginning everything worked fine, and if apparent reason stopped working, could only FTP download through the wifi, call my operadodar telephony and reconfigured the connection data associated with my Phone # number, and since then I started to work again.

Telenia operators sometimes make changes to the confuguracion of data lines without warning and you will not hear of it until you call and I'll check.


greetings to you.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
why are you pulling out an 3 year old thread? Instead you should create a new one.
 
Upvote 0
Top