Android Question FTP error

roberto64

Active Member
Licensed User
Longtime User
FTP error, it is not clear why it gives me this error "(RuntimeException) java.lang.RuntimeException: 550 SSL / TLS required on the control channel"
connection example
help Thanks.

FTP:
Dim ftp As FTP
    ftp.Initialize("FTP", "IP", 21, USER", "PASSWORD")
    ftp.PassiveMode = True
    If ftp.IsInitialized=True Then
        Log("OK FTP!") '
    End If
    
    ftp.UploadFile (File.DirRootExternal, "Camera.png", False, "/Camera.png")
 

NikB4x

Member
Licensed User
Longtime User
Hi,
This means that the server you are using supports only crypted (SSL/TLS) connection.
Usually you can set if it have to support plain text. What server are you using?
 
Upvote 0

NikB4x

Member
Licensed User
Longtime User
If you can't change the plain text setting try this:


B4x:
Dim ftp As FTP
dim ctm As CustomTrustManager
ctm.InitializeAcceptAll
ftp.Initialize("FTP", "IP", 21, USER", "PASSWORD")
ftp.PassiveMode = True
FTP.UseSSL = True
FTP.UseSSLExplicit = True
FTP.SetCustomSSLTrustManager(ctm)
If ftp.IsInitialized=True Then
       Log("OK FTP!") '
End If

ftp.UploadFile (File.DirRootExternal, "Camera.png", False, "/Camera.png")
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Worth reading: https://www.b4x.com/glossary/ftp/

1. No need to check whether ftp.IsInitialized. It will always be after you called Initialize.

2. UseSSL and UseSSLExplicit are exclusive. Only set UseSSLExplicit to True.

3. It is a mistake to post code with CustomTrustManager without explaining what it does. It has security implications. Start without it. It is only needed if you are connecting to a server with a self signed certificate.
 
Upvote 0

NikB4x

Member
Licensed User
Longtime User

Hi Erel you are right, as he is sending camera's pictures to the ftp server, I assumed that he was using an internal server with self signed certificate, but it's not sure and in any case someone else can use the same code for other scope.
So, use ctm.InitializeAcceptAll only if the server hasn't a valid certificate and you know that it's a reliable server.
 
Upvote 0

roberto64

Active Member
Licensed User
Longtime User
Thanks for your reply, but the error persists "android.system.ErrnoException: open failed: ENOENT (No such file or directory)", I don't understand why it tells me that it doesn't find any files or directories.
thank you
 
Upvote 0

NikB4x

Member
Licensed User
Longtime User
This is another kind of error... check if user home dir is correct. What ftp server are you using? Is it under Windows, Linux or other OS?
 
Upvote 0

roberto64

Active Member
Licensed User
Longtime User
the linux ftp server, the program I am using for ftp Filezilla, and the mi directory of which is "/"
thank you
 
Upvote 0

roberto64

Active Member
Licensed User
Longtime User
Yes,
FTP:
#If B4A
    Dim rp As RuntimePermissions
    'PERMISSION_ACCESS_FINE_LOCATION -------------------------------------
    rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    rp.CheckAndRequest(rp.PERMISSION_READ_EXTERNAL_STORAGE)
    Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
        If Result = False Then
        MsgboxAsync("Autorizzazione non autorizzzate", "Attenzione...")
        Return
    End If
    #End If
 
Upvote 0

NikB4x

Member
Licensed User
Longtime User
the linux ftp server, the program I am using for ftp Filezilla, and the mi directory of which is "/"
thank you

So, if I understood,are you using Filezilla server on Linux using WineHQ or something similar? Because I think that Filezilla server isn't native under linux.
In any case the error you are experiencing with, is related to a wrong setting of the user's directory server side.
Could you try to use filezilla as client (also locally) with same user and password for checking if the error is the same? In this way you can check if the problem is server side or client side.
Recently I had the similar problem with vsftpd under linux and the reported error was the same, but the home directory was correctly set and I solved it changing the control port with another than 21. Apparently it had nothing to do with it and with netstat I saw that none was using the 21 port, but It worked.
 
Upvote 0

roberto64

Active Member
Licensed User
Longtime User
No, I'm using Filezilla under windows as a client to connect to the Linux server, I have a third party host / server, its host or server directory and "/" so I don't understand why it can't find the directory or file to upload and save it on my smartphone. Thank you for your time
 
Upvote 0

NikB4x

Member
Licensed User
Longtime User
Have you tried to remove "/"?

ftp.UploadFile (File.DirRootExternal, "Camera.png", False, "Camera.png")
 
Upvote 0

NikB4x

Member
Licensed User
Longtime User
Try to connect here (my test server):

18.219.204.146

user: userftp
pass: userftp

Let me know if it works.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Could it be that your hosting provider doesn't like "/" (root) as the folder on your presumably shared server?
Anyway I find your post #12 a bit confusing; are you uploading from device to server or downloading from server to your device?

"..I have a third party host / server, its host or server directory and "/" so I don't understand why it can't find the directory or file to upload and save it on my smartphone. "
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…