Android Question FTP problems

defillo

Member
Licensed User
Longtime User
Strange question driving me mad

It happens only with certain connections

same app, but different internet connection
connection to a remote server, payed hosting (aruba.it)
configured as

ftp.PassiveMode=True
ftp.UseSSL=False
ftp.UseSSLExplicit=False


what happens:

- I connect using a H3G sim. everything works, all ftp commands are executed

- I connect using landline optifiber connection: at all commands, reply is

501 server cannot accept arguments




connecting with another H3G Sim

same result, 501 server cannot accept arguments

same device, same connection, andFtp app: connection works , all commands executed

Basically, the same app works or not according to the connection (SIM) you have.

net library version 1.80, core 9.00, amdroid 28 sdk

Getting mad about. and most of all, app unusable..

any ideas?

thanks in advance
 
Last edited:

defillo

Member
Licensed User
Longtime User
Erel, thanks for the reply.

I've installed a filezilla server in the office.
Now if I use the other SIM it works. file is correctly uploaded


If I use the landline connection wifi (phone is connected to router wifi) with the App , trying to upload the same file with the app
I get this reply
000006)21/05/2019 19:28:46 - (not logged in) (93.38.67.223)> Connected on port 21, sending welcome message...
(000006)21/05/2019 19:28:46 - (not logged in) (93.38.67.223)> 220-FileZilla Server 0.9.60 beta
(000006)21/05/2019 19:28:46 - (not logged in) (93.38.67.223)> 220-written by Tim Kosse (tim.kosse@filezilla-project.org)
(000006)21/05/2019 19:28:46 - (not logged in) (93.38.67.223)> 220 Please visit https://filezilla-project.org/
(000006)21/05/2019 19:28:46 - (not logged in) (93.38.67.223)> USER guest
(000006)21/05/2019 19:28:46 - (not logged in) (93.38.67.223)> 331 Password required for guest
(000006)21/05/2019 19:28:46 - (not logged in) (93.38.67.223)> PASS *********
(000006)21/05/2019 19:28:46 - guest (93.38.67.223)> 230 Logged on
(000006)21/05/2019 19:28:46 - guest (93.38.67.223)> TYPE A
(000006)21/05/2019 19:28:46 - guest (93.38.67.223)> 200 Type set to A
(000006)21/05/2019 19:28:46 - guest (93.38.67.223)> PORT 100,97,20,179,163,170
(000006)21/05/2019 19:28:46 - guest (93.38.67.223)> 421 Rejected command, requested IP address does not match control connection IP.
and from the app
org.apache.commons.net.ftp.FTPConnectionClosedException: FTP response 421 received. Server closed connection.

BUT

if i use an app like andFTP everything works..

summarize:

if I try to upload from the router wifi with the app and the net library, i get the error
421 Rejected command, requested IP address does not match control connection IP.

if using the same connection but with a commercial app like andFTP, i get a
226 Successfully transferred "....................."

so it really looks like a problem of the library..

this is with the private filezilla, so I can check the messages on the server

No way with the commercial server hosted, and that case also the other sim does not work with
501 server cannot accept arguments

pretty strange, can't get rid of this..
 
Upvote 0

defillo

Member
Licensed User
Longtime User
if you read first post, you'll find ftp.PassiveMode=True

maybe an option to log the server messages should help..


furthermore

with B4i (can connect only with landline as I use b4ibridge) error is
error Error writing to stream: Error Domain=kCFErrorDomainCFNetwork Code=200 "(null)" UserInfo={kCFFTPStatusCodeKey=501, _kCFStreamErrorCodeKey=501, _kCFStreamErrorDomainKey=6}

error 501 appears also on Ios
 
Last edited:
Upvote 0

defillo

Member
Licensed User
Longtime User
some tests

using the app

code:
ftp.PassiveMode=True

ftp.Initialize("ftp","***.***.***.***",21,"guest","*********")
ftp.UseSSLExplicit=False
ftp.UseSSL=False

Dim sftp As Object = ftp.UploadFile(File.dirassets,"starter.bas",True,"starter.bas")
Wait For (sftp) ftp_UploadCompleted (ServerPath As String, Success As Boolean)
ftp.close
If Success=False Then
Log(LastException.Message)

End If

this is the server log

(000424)22/05/2019 22:03:24 - (not logged in) (94.161.242.255)> 220 FileZilla Server 0.9.60 beta
(000424)22/05/2019 22:03:24 - (not logged in) (94.161.242.255)> USER guest
(000424)22/05/2019 22:03:24 - (not logged in) (94.161.242.255)> 331 Password required for guest
(000424)22/05/2019 22:03:24 - (not logged in) (94.161.242.255)> PASS *********
(000424)22/05/2019 22:03:24 - guest (94.161.242.255)> 230 Logged on
(000424)22/05/2019 22:03:24 - guest (94.161.242.255)> TYPE A
(000424)22/05/2019 22:03:24 - guest (94.161.242.255)> 200 Type set to A
(000424)22/05/2019 22:03:24 - guest (94.161.242.255)> PORT 10,129,197,179,158,176
(000424)22/05/2019 22:03:24 - guest (94.161.242.255)> 200 Port command successful
(000424)22/05/2019 22:03:24 - guest (94.161.242.255)> STOR starter.bas
(000424)22/05/2019 22:03:24 - guest (94.161.242.255)> 150 Opening data channel for file upload to server of "/starter.bas"
(000424)22/05/2019 22:03:35 - guest (94.161.242.255)> 425 Can't open data connection for transfer of "/starter.bas"
(000424)22/05/2019 22:04:25 - guest (94.161.242.255)> disconnected.

looks like PASV mode is not entered


same device, same connection but using app "andFtp"

server log

(000423)22/05/2019 22:00:49 - (not logged in) (94.161.242.255)> 220 FileZilla Server 0.9.60 beta
(000423)22/05/2019 22:00:49 - (not logged in) (94.161.242.255)> USER guest
(000423)22/05/2019 22:00:49 - (not logged in) (94.161.242.255)> 331 Password required for guest
(000423)22/05/2019 22:00:50 - (not logged in) (94.161.242.255)> PASS *********
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> 230 Logged on
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> FEAT
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> 211-Features:
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> MDTM
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> REST STREAM
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> SIZE
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> MLST type*;size*;modify*;
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> MLSD
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> UTF8
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> CLNT
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> MFMT
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> EPSV
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> EPRT
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> 211 End
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> CLNT AndFTP
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> 200 Don't care
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> PWD
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> 257 "/" is current directory.
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> NOOP
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> 200 OK
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> CWD /
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> 250 CWD successful. "/" is current directory.
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> FEAT
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> 211-Features:
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> MDTM
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> REST STREAM
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> SIZE
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> MLST type*;size*;modify*;
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> MLSD
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> UTF8
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> CLNT
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> MFMT
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> EPSV
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> EPRT
(000423)22/05/2019 22:00:50 - guest (94.161.242.255)> 211 End
(000423)22/05/2019 22:00:51 - guest (94.161.242.255)> PASV
(000423)22/05/2019 22:00:51 - guest (94.161.242.255)> 227 Entering Passive Mode (192,168,0,157,240,94)
(000423)22/05/2019 22:00:51 - guest (94.161.242.255)> MLSD
(000423)22/05/2019 22:00:51 - guest (94.161.242.255)> 150 Opening data channel for directory listing of "/"
(000423)22/05/2019 22:00:51 - guest (94.161.242.255)> 226 Successfully transferred "/"
(000423)22/05/2019 22:01:01 - guest (94.161.242.255)> NOOP
(000423)22/05/2019 22:01:01 - guest (94.161.242.255)> 200 OK
(000423)22/05/2019 22:01:01 - guest (94.161.242.255)> TYPE I
(000423)22/05/2019 22:01:01 - guest (94.161.242.255)> 200 Type set to I
(000423)22/05/2019 22:01:01 - guest (94.161.242.255)> CWD /
(000423)22/05/2019 22:01:01 - guest (94.161.242.255)> 250 CWD successful. "/" is current directory.
(000423)22/05/2019 22:01:02 - guest (94.161.242.255)> SYST
(000423)22/05/2019 22:01:02 - guest (94.161.242.255)> 215 UNIX emulated by FileZilla
(000423)22/05/2019 22:01:02 - guest (94.161.242.255)> PASV
(000423)22/05/2019 22:01:02 - guest (94.161.242.255)> 227 Entering Passive Mode (192,168,0,157,195,244)
(000423)22/05/2019 22:01:02 - guest (94.161.242.255)> LIST
(000423)22/05/2019 22:01:02 - guest (94.161.242.255)> 150 Opening data channel for directory listing of "/"
(000423)22/05/2019 22:01:02 - guest (94.161.242.255)> 226 Successfully transferred "/"
(000423)22/05/2019 22:01:02 - guest (94.161.242.255)> PASV
(000423)22/05/2019 22:01:02 - guest (94.161.242.255)> 227 Entering Passive Mode (192,168,0,157,206,37)
(000423)22/05/2019 22:01:02 - guest (94.161.242.255)> STOR 20190421_053617.jpg
(000423)22/05/2019 22:01:02 - guest (94.161.242.255)> 150 Opening data channel for file upload to server of "/20190421_053617.jpg"
(000423)22/05/2019 22:01:12 - guest (94.161.242.255)> 226 Successfully transferred "/20190421_053617.jpg"
(000423)22/05/2019 22:03:13 - guest (94.161.242.255)> 421 Connection timed out.

PASV mode is correctly entered

actually I am trying with 3 different connections. one is working, one does not enter PASV mode, and the other one gives 501 error..


501 error also with b4i, and in this case I cannot test other connections due to bridge connection



totally stuck as app MUST work with ALL connections...
 
Upvote 0

defillo

Member
Licensed User
Longtime User
and

I've tried adding ftp.sendcommand("PASV","") and server jumps back in TYPE A

(000438)22/05/2019 22:33:57 - (not logged in) (94.161.242.255)> 220 FileZilla Server 0.9.60 beta
(000438)22/05/2019 22:33:57 - (not logged in) (94.161.242.255)> USER guest
(000438)22/05/2019 22:33:57 - (not logged in) (94.161.242.255)> 331 Password required for guest
(000438)22/05/2019 22:33:57 - (not logged in) (94.161.242.255)> PASS *********
(000438)22/05/2019 22:33:57 - guest (94.161.242.255)> 230 Logged on
(000438)22/05/2019 22:33:57 - guest (94.161.242.255)> PASV
(000438)22/05/2019 22:33:57 - guest (94.161.242.255)> 227 Entering Passive Mode (192,168,0,157,197,233)
(000438)22/05/2019 22:33:57 - guest (94.161.242.255)> TYPE A
(000438)22/05/2019 22:33:57 - guest (94.161.242.255)> 200 Type set to A
(000438)22/05/2019 22:33:57 - guest (94.161.242.255)> PORT 10,129,197,179,182,248
(000438)22/05/2019 22:33:57 - guest (94.161.242.255)> 200 Port command successful
(000438)22/05/2019 22:33:57 - guest (94.161.242.255)> STOR \0.jpg
(000438)22/05/2019 22:33:57 - guest (94.161.242.255)> 150 Opening data channel for file upload to server of "/0.jpg"
(000438)22/05/2019 22:34:08 - guest (94.161.242.255)> 425 Can't open data connection for transfer of "/0.jpg"
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Have you tried to set pasive mode after initialize?
 
Upvote 0
Top