Android Question Help to upload file by FTPSERVER

Omar Moreno

Member
Licensed User
Longtime User
Greetings to all, forgive my English, translated with google.

I'm using the FTPSERVER classes for B4A on a Tablet with Android 4.4.
Start the server with these parameters:

B4X:
        Server.Initialize(Main, "FTPServer")
        Server.SetPorts(51041, 51042, 51142)
        Server.AddUser("Test", "test")
        Server.BaseDir = File.DirRootExternal
        Server.Start        '
        Lbl_IP_Wifi.Text = Server.ssocket.GetMyWifiIP
        Lbl_IP_Ethernet.Text = Server.ssocket.GetMyIP
        Lbl_Puerto.Text = Server.Port
        Lbl_Path.Text = Server.BaseDir

The subroutine in Visual Studio is

B4X:
Private Sub Conectar_Copiar_Sqlite_FTP(ByVal XArchivo As String)
'
Try
    '
    Dim ArchivoSubir As String = Ruta_Salida_Local & XArchivo
    '
    Dim RutaFTPCel As String = "ftp://192.168.3.2:51041/Application/Inv1/Entrada/" & XArchivo
        '
    My.Computer.Network.UploadFile(ArchivoSubir,RutaFTPCel,"Test","test",True,1000,FileIO.UICancelOption.DoNothing)
    '
Catch ex As Exception
    '
    MessageBox.Show("El siguiente error a ocurrido mientras se copiaba el SQLite." & _
        vbCrLf & vbCrLf & ex.Message, "Error")
    '
End Try
    '
End Sub

when I run the client to send the file to the Tablet it generates an error message:

Exception during the WebClient request

I run it again and the error changes to this:

error on remote server: 227 192,168,3,2,199,99

in debug mode, in the log, these messages emerge:

client: USER Test
client: PASS test
User logged in: Test
client: OPTS utf8 on
client: PWD
client: TYPE I
client: PASV
terminated

from a Windows window after two attempts:

client: USER anonymous
client: PASS User@nada.com
Error: Invalid username or password.
terminated
client: USER anonymous
client: PASS User@nada.com
Error: Invalid username or password.
terminated
client: USER Test
client: PASS test
User logged in: Test
client: opts utf8 on
client: syst
client: site help
client: PWD
client: USER Test
client: PASS
Error: Invalid username or password.
terminated
terminated
terminated
client: USER Test
client: PASS
Error: Invalid username or password.
terminated
client: USER Test
client: PASS test
User logged in: Test
client: opts utf8 on
client: syst
client: site help
client: PWD
client: CWD /Application/Inv1/Entrada/
CurrentPath: /Application/Inv1/Entrada
client: TYPE A
client: PASV
client: LIST
Data connection terminated: /Application/Inv1/Entrada

Thank you for your answers.
 

Attachments

  • FTPSERVER.png
    FTPSERVER.png
    18.5 KB · Views: 284

OliverA

Expert
Licensed User
Longtime User
My guess? There is something wrong with your client. For some reason it does not seam to process the PASV returned information properly, the
227 192,168,3,2,199,98
It could be that the Visual Studio FTP client implementation is expecting a different format of response, such as
227 Entering Passive Mode (213,229,112,130,216,4)
, but no format is specified in the RFC (959) (https://tools.ietf.org/html/rfc959), which is reiterated in RFC (1123) (http://tools.ietf.org/html/rfc1123#page-31). So if that is the case (your client is expecting a different format), then the issue lies with your client.

Resource: Stackoverflow question/answer (https://stackoverflow.com/questions/14498331/what-should-be-the-ftp-response-to-pasv-command)
 
Upvote 0
Top