FTP upload: 425 Can't open data connection.

mcorbeel

Active Member
Licensed User
Longtime User
Hi all, i'm a new user, and started programming with basic4android yesterday.
I try to upload a file using FTP and always get error "425 Can't open data connection" after 10 seconds on my FileZilla server. I use NET library 1.11 and have tried both PassiveMode = True and PassiveMode = False. Anyone a solution?

Code:
Dim oFTP As FTP
File.WriteString(File.DirInternal,"test.txt","xxxxxxxxxxxxxxxxxxx")
oFTP.Initialize( "FTP", ftp_servername , 21, username, password)
oFTP.PassiveMode = True -> (also tried False)
oFTP.UploadFile( File.DirInternal, "test.txt", True, "/test.txt")
 

Rogerardo

Member
Licensed User
Longtime User
The problem is not just related to FileZilla. I get the same error with Bulletproof FTP Server, both 2007 version and the current version. Also with Ipswitch FTP server. BPFTP server which I have used for many years works fine with SwiFTP for Android when you set SwiFTP to Passive mode but when you set it to Active mode you get the 425 error. This makes me think the problem is with the Passive mode setting in the Basic4Android system.
 
Upvote 0

Rogerardo

Member
Licensed User
Longtime User
Program Source:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Summary")
JobSummary.Initialize("JobSummary")
FTP.Initialize("FTP", "10.0.0.12", 21, "android", "androidftp")
FTP.PassiveMode=True

End Sub

Sub FTPDownload_Click
Dim files As List
If (FTP.IsInitialized) Then
FTP.DownloadFile("1.txt", False, File.DirInternal, "1.txt")
End If

End Sub

The IP address' I have used are: Windows XP Pro machine, Server 2008 machine internal address, same machine, external address.


FTP server is BulletProof FTP Server
Same error in Ipswitch FTP Server and FileZilla.
Fails with same error for Upload, Download, List.
Same error for SwiFTP in Active mode but SwiFTP in Passive mode works fine.

Server Log:

---------- Session created on 26/09/11 11:59:21 on port 21 ----------

26/09/11 11:59:21 - FTP Server On-line : IP(s) 10.0.0.12, on port 21
(000001) 26/09/11 12:00:41 - (not logged in) (10.0.0.13) > connected to ip : 10.0.0.12
(000001) 26/09/11 12:00:41 - (not logged in) (10.0.0.13) > sending welcome message.
(000001) 26/09/11 12:00:41 - (not logged in) (10.0.0.13) > 220 BulletProof FTP Server ready ...
(000001) 26/09/11 12:00:41 - (not logged in) (10.0.0.13) > USER android
(000001) 26/09/11 12:00:41 - (not logged in) (10.0.0.13) > 331 Password required for android.
(000001) 26/09/11 12:00:42 - (not logged in) (10.0.0.13) > PASS ********
(000001) 26/09/11 12:00:42 - android (10.0.0.13) > logged in.
(000001) 26/09/11 12:00:42 - android (10.0.0.13) > 230 User android logged in.
(000001) 26/09/11 12:00:42 - android (10.0.0.13) > TYPE I
(000001) 26/09/11 12:00:42 - android (10.0.0.13) > 200 Type set to I.
(000001) 26/09/11 12:00:42 - android (10.0.0.13) > PORT 10,0,2,2,194,154
(000001) 26/09/11 12:00:42 - android (10.0.0.13) > 200 Port command successful.
(000001) 26/09/11 12:00:42 - android (10.0.0.13) > RETR 1.txt
(000001) 26/09/11 12:00:42 - android (10.0.0.13) > asked to download 'R:\androidftp\1.txt' --> Access allowed.
(000001) 26/09/11 12:00:42 - android (10.0.0.13) > 150 Opening data connection for 1.txt (152 bytes).
(000001) 26/09/11 12:01:03 - android (10.0.0.13) > 425 Cannot open data connection (10060).
(000001) 26/09/11 12:06:48 - android (10.0.0.13) > disconnected. (00:06:06)


---------- Session closed on 26/09/11 12:18:09 ----------
 
Upvote 0

Rogerardo

Member
Licensed User
Longtime User
FTP Log for success and failure from AndFTP to Filezilla: Same symptoms with BPFTP ftp server.


FileZilla Server version 0.9.39 beta
Copyright 2001-2011 by Tim Kosse (tim.kosse@filezilla-project.org)
Connecting to server...
Connected, waiting for authentication
Logged on
(004294)27/09/11 09:54:11 - (not logged in) (92.40.254.65)> Connected, sending welcome message...
(004294)27/09/11 09:54:11 - (not logged in) (92.40.254.65)> 220-FileZilla Server version 0.9.39 beta
(004294)27/09/11 09:54:11 - (not logged in) (92.40.254.65)> 220-written by Tim Kosse (Tim.Kosse@gmx.de)
(004294)27/09/11 09:54:11 - (not logged in) (92.40.254.65)> 220 Please visit FileZilla | Free File Sharing software downloads at SourceForge.net


AndFTP set to Passive Mode:

(004294)27/09/11 09:54:12 - (not logged in) (92.40.254.65)> USER android
(004294)27/09/11 09:54:12 - (not logged in) (92.40.254.65)> 331 Password required for android
(004294)27/09/11 09:54:12 - (not logged in) (92.40.254.65)> PASS **********
(004294)27/09/11 09:54:12 - android (92.40.254.65)> 230 Logged on
(004294)27/09/11 09:54:12 - android (92.40.254.65)> FEAT
(004294)27/09/11 09:54:12 - android (92.40.254.65)> 211-Features:
(004294)27/09/11 09:54:12 - android (92.40.254.65)> MDTM
(004294)27/09/11 09:54:12 - android (92.40.254.65)> REST STREAM
(004294)27/09/11 09:54:12 - android (92.40.254.65)> SIZE
(004294)27/09/11 09:54:12 - android (92.40.254.65)> MLST type*;size*;modify*;
(004294)27/09/11 09:54:12 - android (92.40.254.65)> MLSD
(004294)27/09/11 09:54:12 - android (92.40.254.65)> UTF8
(004294)27/09/11 09:54:12 - android (92.40.254.65)> CLNT
(004294)27/09/11 09:54:12 - android (92.40.254.65)> MFMT
(004294)27/09/11 09:54:12 - android (92.40.254.65)> 211 End
(004294)27/09/11 09:54:12 - android (92.40.254.65)> CLNT AndFTP
(004294)27/09/11 09:54:12 - android (92.40.254.65)> 200 Don't care
(004294)27/09/11 09:54:12 - android (92.40.254.65)> CWD /
(004294)27/09/11 09:54:12 - android (92.40.254.65)> 250 CWD successful. "/" is current directory.
(004294)27/09/11 09:54:12 - android (92.40.254.65)> PASV
(004294)27/09/11 09:54:12 - android (92.40.254.65)> 227 Entering Passive Mode (10,0,0,200,180,4)
(004294)27/09/11 09:54:12 - android (92.40.254.65)> MLSD
(004294)27/09/11 09:54:12 - android (92.40.254.65)> 150 Connection accepted
(004294)27/09/11 09:54:12 - android (92.40.254.65)> 226 Transfer OK
(004295)27/09/11 09:54:18 - (not logged in) (92.40.254.65)> Connected, sending welcome message...
(004295)27/09/11 09:54:18 - (not logged in) (92.40.254.65)> 220-FileZilla Server version 0.9.39 beta
(004295)27/09/11 09:54:18 - (not logged in) (92.40.254.65)> 220-written by Tim Kosse (Tim.Kosse@gmx.de)
(004295)27/09/11 09:54:18 - (not logged in) (92.40.254.65)> 220 Please visit FileZilla | Free File Sharing software downloads at SourceForge.net
(004295)27/09/11 09:54:18 - (not logged in) (92.40.254.65)> USER android
(004295)27/09/11 09:54:18 - (not logged in) (92.40.254.65)> 331 Password required for android
(004295)27/09/11 09:54:18 - (not logged in) (92.40.254.65)> PASS **********
(004295)27/09/11 09:54:18 - android (92.40.254.65)> 230 Logged on
(004295)27/09/11 09:54:19 - android (92.40.254.65)> FEAT
(004295)27/09/11 09:54:19 - android (92.40.254.65)> 211-Features:
(004295)27/09/11 09:54:19 - android (92.40.254.65)> MDTM
(004295)27/09/11 09:54:19 - android (92.40.254.65)> REST STREAM
(004295)27/09/11 09:54:19 - android (92.40.254.65)> SIZE
(004295)27/09/11 09:54:19 - android (92.40.254.65)> MLST type*;size*;modify*;
(004295)27/09/11 09:54:19 - android (92.40.254.65)> MLSD
(004295)27/09/11 09:54:19 - android (92.40.254.65)> UTF8
(004295)27/09/11 09:54:19 - android (92.40.254.65)> CLNT
(004295)27/09/11 09:54:19 - android (92.40.254.65)> MFMT
(004295)27/09/11 09:54:19 - android (92.40.254.65)> 211 End
(004295)27/09/11 09:54:19 - android (92.40.254.65)> CLNT AndFTP
(004295)27/09/11 09:54:19 - android (92.40.254.65)> 200 Don't care
(004295)27/09/11 09:54:19 - android (92.40.254.65)> CWD /
(004295)27/09/11 09:54:19 - android (92.40.254.65)> 250 CWD successful. "/" is current directory.
(004295)27/09/11 09:54:19 - android (92.40.254.65)> PASV
(004295)27/09/11 09:54:19 - android (92.40.254.65)> 227 Entering Passive Mode (10,0,0,200,180,5)
(004295)27/09/11 09:54:19 - android (92.40.254.65)> MLSD
(004295)27/09/11 09:54:19 - android (92.40.254.65)> 150 Connection accepted
(004295)27/09/11 09:54:19 - android (92.40.254.65)> 226 Transfer OK
(004295)27/09/11 09:54:42 - android (92.40.254.65)> NOOP
(004295)27/09/11 09:54:42 - android (92.40.254.65)> 200 OK
(004295)27/09/11 09:54:43 - android (92.40.254.65)> TYPE I
(004295)27/09/11 09:54:43 - android (92.40.254.65)> 200 Type set to I
(004295)27/09/11 09:54:43 - android (92.40.254.65)> TYPE I
(004295)27/09/11 09:54:43 - android (92.40.254.65)> 200 Type set to I
(004295)27/09/11 09:54:43 - android (92.40.254.65)> PASV
(004295)27/09/11 09:54:43 - android (92.40.254.65)> 227 Entering Passive Mode (10,0,0,200,180,9)
(004295)27/09/11 09:54:44 - android (92.40.254.65)> RETR /mr_0S_01579.txt
(004295)27/09/11 09:54:44 - android (92.40.254.65)> 150 Connection accepted
(004295)27/09/11 09:54:44 - android (92.40.254.65)> 226 Transfer OK
(004295)27/09/11 09:54:50 - android (92.40.254.65)> NOOP
(004295)27/09/11 09:54:50 - android (92.40.254.65)> 200 OK
(004295)27/09/11 09:54:50 - android (92.40.254.65)> CWD /
(004295)27/09/11 09:54:50 - android (92.40.254.65)> 250 CWD successful. "/" is current directory.
(004295)27/09/11 09:54:51 - android (92.40.254.65)> PASV
(004295)27/09/11 09:54:51 - android (92.40.254.65)> 227 Entering Passive Mode (10,0,0,200,180,10)
(004295)27/09/11 09:54:52 - android (92.40.254.65)> disconnected.



AndFTP set to Active Mode:


(004296)27/09/11 09:55:08 - (not logged in) (92.40.254.65)> Connected, sending welcome message...
(004296)27/09/11 09:55:08 - (not logged in) (92.40.254.65)> 220-FileZilla Server version 0.9.39 beta
(004296)27/09/11 09:55:08 - (not logged in) (92.40.254.65)> 220-written by Tim Kosse (Tim.Kosse@gmx.de)
(004296)27/09/11 09:55:08 - (not logged in) (92.40.254.65)> 220 Please visit FileZilla | Free File Sharing software downloads at SourceForge.net
(004296)27/09/11 09:55:09 - (not logged in) (92.40.254.65)> USER android
(004296)27/09/11 09:55:09 - (not logged in) (92.40.254.65)> 331 Password required for android
(004296)27/09/11 09:55:09 - (not logged in) (92.40.254.65)> PASS **********
(004296)27/09/11 09:55:09 - android (92.40.254.65)> 230 Logged on
(004296)27/09/11 09:55:10 - android (92.40.254.65)> FEAT
(004296)27/09/11 09:55:10 - android (92.40.254.65)> 211-Features:
(004296)27/09/11 09:55:10 - android (92.40.254.65)> MDTM
(004296)27/09/11 09:55:10 - android (92.40.254.65)> REST STREAM
(004296)27/09/11 09:55:10 - android (92.40.254.65)> SIZE
(004296)27/09/11 09:55:10 - android (92.40.254.65)> MLST type*;size*;modify*;
(004296)27/09/11 09:55:10 - android (92.40.254.65)> MLSD
(004296)27/09/11 09:55:10 - android (92.40.254.65)> UTF8
(004296)27/09/11 09:55:10 - android (92.40.254.65)> CLNT
(004296)27/09/11 09:55:10 - android (92.40.254.65)> MFMT
(004296)27/09/11 09:55:10 - android (92.40.254.65)> 211 End
(004296)27/09/11 09:55:11 - android (92.40.254.65)> CLNT AndFTP
(004296)27/09/11 09:55:11 - android (92.40.254.65)> 200 Don't care
(004296)27/09/11 09:55:11 - android (92.40.254.65)> CWD /
(004296)27/09/11 09:55:11 - android (92.40.254.65)> 250 CWD successful. "/" is current directory.
(004296)27/09/11 09:55:11 - android (92.40.254.65)> PORT 92,40,254,65,235,92
(004296)27/09/11 09:55:11 - android (92.40.254.65)> 200 Port command successful
(004296)27/09/11 09:55:11 - android (92.40.254.65)> MLSD
(004296)27/09/11 09:55:11 - android (92.40.254.65)> 150 Opening data channel for directory list.
(004296)27/09/11 09:55:22 - android (92.40.254.65)> 425 Can't open data connection.
(004296)27/09/11 09:55:25 - android (92.40.254.65)> disconnected.
(004294)27/09/11 09:55:49 - android (92.40.254.65)> disconnected.
 
Upvote 0

sgarabinas

Member
Licensed User
Longtime User
The PASV command doesn't show in the ftp server log like when you connect with AndFtp or Filezilla, so maybe the server don't get the command to get in passive mode.
 
Upvote 0

sgarabinas

Member
Licensed User
Longtime User
In Activity_Create:

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("modupd")
If FirstTime Then
Dim cInf As Cursor
cInf = main.Db.ExecQuery("Select _id, IpAddr, FtpLog, FtpPas, LasSen From Inf")
cInf.Position=0
xIpAddr = cInf.GetString("IpAddr")
xFtpLog = cInf.GetString("FtpLog")
xFtpPas = cInf.GetString("FtpPas")
FTP.PassiveMode=True
FTP.Initialize("FTP",xIpAddr,21,xFtpLog,xFtpPas)
End If
End Sub

And in the Button click:

Sub BtnUpd_Click
Dim p As Phone
Dim s As String
s=p.GetDataState
If p.GetDataState="CONNECTED" Then
File.Delete(File.DirRootExternal,"DbNew.db3")
Dim sDir As String
Dim tDir As String
sDir = "/" &xFtpLog& "/Update/DbNew.db3"
tDir = File.DirRootExternal &"/"
If FTP.IsInitialized = False Then
FTP.PassiveMode=True
FTP.Initialize("FTP",xIpAddr,21,xFtpLog,xFtpPas)
End If
FTP.DownloadFile(sDir, False, File.DirRootExternal,"DbNew.db3")
Else
Msgbox("Δεν υπάρχει σύνδεση","Πρόβλημα")
End If
End Sub
 
Upvote 0

sgarabinas

Member
Licensed User
Longtime User
Found the problem....

The FTP.PassiveMode=True must be before the FTP.DownloadFile and not before the FTP.Initialize

It works fine now

Thank you for your replies and your patience
 
Upvote 0

Rogerardo

Member
Licensed User
Longtime User
I have just downloaded the latest version as at 29/9/11 and can confirm the Passive parameter now appears to be working. Many thanks Erel.
 
Upvote 0
Top