B4J Question [Solved]FTP Download file from IONOS Hidrive

schimanski

Well-Known Member
Licensed User
Longtime User
Does anyone have experience with IONOS FTP? I have enabled the FTP protocol, but unfortunately I can't access the files. Do I need to use a different configuration?

B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    FTP.Initialize("FTP", "sftp.hidrive.ionos.com", 22, "[email protected]", "xxxxxx")
    FTP.UseSSL=True
    FTP.TimeoutMs=5000
    FTP.List("/")
End Sub

Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
    Log(ServerPath)
    If Success = False Then
        Log(LastException)
    Else
        For i = 0 To Folders.Length - 1
            Log(Folders(i).Name)
        Next
        For i = 0 To Files.Length - 1
            Log(Files(i).Name & ", " & Files(i).Size & ", " & DateTime.Date(Files(i).Timestamp))
        Next
    End If
End Sub

if is set UseSSL to true, i get this exception:
(SSLException) javax.net.ssl.SSLException: Unsupported or unrecognized SSL message

Without setting UseSSL to true
(SocketTimeoutException) java.net.SocketTimeoutException: Read timed out

with setting UseSSLExplicit to true on port 21:
(ConnectException) java.net.ConnectException: Connection refused: connect

The configurations of the IONOS Hidrive FTP from the manual:
Bezeichnung SFTP FTPS
Server sftp.hidrive.ionos.com ftp.hidrive.ionos.com
Benutzername Ihr HiDrive-Benutzername Ihr HiDrive-Benutzername
Passwort Ihr HiDrive-Passwort Ihr HiDrive-Passwort
Port 22 21 (explizit mit TLS-Verschlüsselung)


It is no problem, to use it with Filezilla.
 

teddybear

Well-Known Member
Licensed User
You should connect to the server ftp.hidrive.ionos.com instead of sftp.hidrive.ionos.com. and port set to 21
ftps is not sftp.
 
Last edited:
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
Thanks you, for your answer. I tried different configurations. With the following, the ListCompleted is success, but the list of folder and files are always emty, even if I specify the directories explicitly:

B4X:
    FTP.Initialize("FTP", "ftp.hidrive.ionos.com", 21, "[email protected]", "xxxxx")
    FTP.UseSSLExplicit=True
    FTP.TimeoutMs=5000
    FTP.List("\")
    
End Sub

Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
    Log(ServerPath)
    If Success = False Then
        Log(LastException)
    Else
        Log(Folders.Length)
        Log(Files.Length)
        For i = 0 To Folders.Length - 1
            Log(Folders(i).Name)
        Next
        For i = 0 To Files.Length - 1
            Log(Files(i).Name & ", " & Files(i).Size & ", " & DateTime.Date(Files(i).Timestamp))
        Next
    End If
End Sub
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Have you tried to use passivemode?

 
Last edited:
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
That's it. I hadn't thought of it. Thank you. That's the code:

B4X:
    FTP.Initialize("FTP", "ftp.hidrive.ionos.com", 21, "[email protected]", "xxxxxx")
    FTP.PassiveMode=True
    FTP.UseSSLExplicit=True
    FTP.TimeoutMs=5000
    FTP.List(".")

and here the result:
.
2
0
public
users
Perfect!
 
Upvote 0
Solution
Top