B4J Question [SOLVED] Ftp session issue

NikB4x

Member
Licensed User
Longtime User
Hi All,
I'm going crazy with this problem:
I have installed a vsftpd server with autogenerated SSL on linux and I'm trying to do a simple upload of a file via code from B4j.

This is the code:

B4J:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private FTPHostName As String="192.168.2.127"
    Private FTPUsername As String="user"
    Private FTPPassword As String="password"
    
End Sub

Public Sub Initialize
    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Private Sub Button1_Click
        Dim FTP As FTP
        FTP.PassiveMode = False
        FTP.UseSSLExplicit=True
        Dim ssltrustmanager As CustomTrustManager
        ssltrustmanager.initializeAcceptAll
        FTP.SetCustomSSLTrustManager(ssltrustmanager)
        FTP.Initialize("ftp1", FTPHostName, 21, FTPUsername, FTPPassword)
        FTP.UploadFile("C:\", "test.txt", False, "/data/test.txt")
        Wait For ftp1_UploadCompleted (serverpath As String, success As Boolean)
        FTP.Close
        If success Then Return
        Sleep(1000)
End Sub

This is the error:

*** mainpage: B4XPage_Created
*** mainpage: B4XPage_Appear
*** mainpage: B4XPage_Resize [mainpage]
java.lang.RuntimeException: 530 Non-anonymous sessions must use encryption.
at anywheresoftware.b4a.net.FTPWrapper.connectIfNeeded(FTPWrapper.java:521)
at anywheresoftware.b4a.net.FTPWrapper.access$3(FTPWrapper.java:485)
at anywheresoftware.b4a.net.FTPWrapper$2.run(FTPWrapper.java:225)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1589)
*** mainpage: B4XPage_Disappear [mainpage]

If I use Filezilla to upload the same file with the same parameters, it works well.
Where am I going wrong?
Thanks in advance!
 
Top