Discuss (FTP), (FTP on .NET CF) and (FTPS, SFTP and SCP).
no avatar
User

mcpsspa

Posts

6

Joined

Thu Nov 16, 2006 5:30 am

Issue with Active Mode and Port command

by mcpsspa » Thu Nov 16, 2006 5:42 am

Hi all,

We're uploading several csv files to a remote server that requires active transfer mode. I've also tested this with our FTP server; passive mode works but active mode fails with this error message:

Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

It seems the Port command never reaches the remote host. In the log, his is what is sent just before the error (IP masked for obvious reasons):

FTP command sent: ---> PORT XXX,XX,XX,XXX,9,222

I've also tested both modes manually with FileZilla and can transfer in either mode successfully. I can't understand the problem.

The code (VB.NET) used to set up & perform the transfer is (called in the order it appears):

FTPConn.ServerAddress = FTPServerURI
FTPConn.ServerPort = FTPPort
FTPConn.Timeout = 300000
FTPConn.AutoLogin = False
FTPConn.UserName = FTPUserName
FTPConn.Password = FTPPassword
FTPConn.Connect()
FTPConn.Login()
FTPConn.ConnectMode = EnterpriseDT.Net.Ftp.FTPConnectMode.ACTIVE
FTPConn.TransferType = EnterpriseDT.Net.Ftp.FTPTransferType.ASCII
FTPUpload(CSVFilePath & AttendanceCSVFileName, FTPPath & AttendanceCSVFileName)

All the variables being assigned have valid values.

I'm stumped, any help is greatly appreciated

Thanks
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: Issue with Active Mode and Port command

by support2 » Thu Nov 16, 2006 9:06 am

Post the log file so we can see a bit better what is going on
no avatar
User

mcpsspa

Posts

6

Joined

Thu Nov 16, 2006 5:30 am

by mcpsspa » Fri Nov 17, 2006 1:08 am

Thanks Bruce, here's the log:

DEBUG [EnterpriseDT.Net.HostNameResolver] 16 Nov 2006 10:05:46.422 : XXX.XXX.XXX.XXX resolved to XXX.XXX.XXX.XXX
DEBUG [EnterpriseDT.Net.Ftp.FTPClient] 16 Nov 2006 10:05:46.422 : Connecting to XXX.XXX.XXX.XXX:21
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 16 Nov 2006 10:05:46.438 : 220 Microsoft FTP Service
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:46.438 : Invoking delegate EnterpriseDT.Net.Ftp.FTPConnectionEventHandler
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:46.438 : Finding MainWindowHandle
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:46.454 : No MainWindowHandle found
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:46.454 : No GUI control
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:46.454 : Invoking delegate dynamically
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:46.454 : Dynamic delegate invocation complete
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 16 Nov 2006 10:05:46.454 : ---> USER xxxxxxx
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 16 Nov 2006 10:05:46.454 : 331 Password required for sfitsp04.
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 16 Nov 2006 10:05:46.454 : ---> PASS ********
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 16 Nov 2006 10:05:46.454 : 230 User sfitsp04 logged in.
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:46.454 : Invoking delegate EnterpriseDT.Net.Ftp.FTPLogInEventHandler
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:46.454 : No GUI control
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:46.454 : Invoking delegate dynamically
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:46.454 : Dynamic delegate invocation complete
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 16 Nov 2006 10:05:46.454 : ---> TYPE A
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 16 Nov 2006 10:05:46.454 : 200 Type set to A.
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:46.469 : Invoking delegate EnterpriseDT.Net.Ftp.FTPFileTransferEventHandler
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:46.469 : No GUI control
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:46.469 : Invoking delegate dynamically
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:46.469 : Dynamic delegate invocation complete
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 16 Nov 2006 10:05:46.469 : NewActiveDataSocket(0)
INFO [EnterpriseDT.Net.Ftp.FTPControlSocket] 16 Nov 2006 10:05:46.469 : Forcing use of fixed IP for PORT command
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 16 Nov 2006 10:05:46.469 : ---> PORT XXX,XXX,XXX,XXX,13,37
ERROR [EnterpriseDT.Net.Ftp.FTPControlSocket] 16 Nov 2006 10:05:47.939 : Failed to create listening socket : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadLine()
at EnterpriseDT.Net.Ftp.FTPControlSocket.ReadReply()
at EnterpriseDT.Net.Ftp.FTPControlSocket.SendCommand(String command)
at EnterpriseDT.Net.Ftp.FTPControlSocket.SetDataPort(IPEndPoint ep)
at EnterpriseDT.Net.Ftp.FTPControlSocket.NewActiveDataSocket(Int32 port)
CAUSED BY:
System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
ERROR [EnterpriseDT.Net.Ftp.FTPClient] 16 Nov 2006 10:05:48.017 : Caught exception : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
at EnterpriseDT.Net.Ftp.FTPControlSocket.NewActiveDataSocket(Int32 port)
at EnterpriseDT.Net.Ftp.FTPControlSocket.CreateDataSocketActive()
at EnterpriseDT.Net.Ftp.FTPControlSocket.CreateDataSocket(FTPConnectMode connectMode)
at EnterpriseDT.Net.Ftp.FTPClient.InitPut(String remoteFile, Boolean append)
at EnterpriseDT.Net.Ftp.FTPClient.PutASCII(Stream srcStream, String remoteFile, Boolean append)
CAUSED BY:
System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:48.017 : Invoking delegate EnterpriseDT.Net.Ftp.FTPFileTransferEventHandler
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:48.017 : No GUI control
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:48.017 : Invoking delegate dynamically
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:48.017 : Dynamic delegate invocation complete
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 16 Nov 2006 10:05:48.017 : ---> QUIT
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:48.017 : Invoking delegate EnterpriseDT.Net.Ftp.FTPConnectionEventHandler
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:48.017 : No GUI control
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:48.017 : Invoking delegate dynamically
DEBUG [EnterpriseDT.Net.Ftp.FTPConnection] 16 Nov 2006 10:05:48.017 : Dynamic delegate invocation complete
no avatar
User

EDT Support

Posts

905

Joined

Mon Apr 26, 2004 3:03 pm

by EDT Support » Fri Nov 17, 2006 7:21 am

This could be caused by a firewall interfering with the incoming data connection. Have you tried using passive mode?

- Hans (EDT)
no avatar
User

mcpsspa

Posts

6

Joined

Thu Nov 16, 2006 5:30 am

by mcpsspa » Fri Nov 17, 2006 7:28 am

Hans, thanks for the reply. Yes, passive mode works fine but for the production version, files will be transferred to a service that requires active mode. I have tested the firewall question by using an FTP client (FileZilla) to transfer files in both modes directly from the server the application is running on. Both modes work without a problem so I can't see where it would be a firewall issue.

I'm now taking the approach of instantiating the FTP client rather than using the toolbox component. So far, I am still having some issues. If you can think of any other reason the above may be failing, please let me know.

Thanks

David
no avatar
User

EDT Support

Posts

905

Joined

Mon Apr 26, 2004 3:03 pm

by EDT Support » Fri Nov 17, 2006 7:38 am

no avatar
User

mcpsspa

Posts

6

Joined

Thu Nov 16, 2006 5:30 am

by mcpsspa » Fri Nov 17, 2006 7:46 am

no avatar
User

EDT Support

Posts

905

Joined

Mon Apr 26, 2004 3:03 pm

by EDT Support » Fri Nov 17, 2006 8:03 am

no avatar
User

mcpsspa

Posts

6

Joined

Thu Nov 16, 2006 5:30 am

by mcpsspa » Fri Nov 17, 2006 11:51 pm

no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Sat Nov 18, 2006 12:54 am

no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Sat Nov 18, 2006 1:36 am

Last edited by support2 on Sat Nov 18, 2006 3:06 am, edited 1 time in total.
no avatar
User

mcpsspa

Posts

6

Joined

Thu Nov 16, 2006 5:30 am

by mcpsspa » Sat Nov 18, 2006 1:49 am

no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Sat Nov 18, 2006 3:08 am

no avatar
User

Aykut

Posts

3

Joined

Wed Apr 14, 2010 11:10 pm

by Aykut » Wed Apr 14, 2010 11:16 pm

Hello,
I have the same problem.
My application works on my machine but when I install it to server I have this message :

-----> Hotelbeds :GetFtpArchiveStream ERR : EnterpriseDT.Net.Ftp.ControlChannelIOException: Impossible de lire les donn?es de la connexion de transport : Une connexion existante a d? ?tre ferm?e par l'h?te distant.
EnterpriseDT.Net.Ftp.FTPControlSocket.ReadLine()
EnterpriseDT.Net.Ftp.FTPControlSocket.ReadReply()
EnterpriseDT.Net.Ftp.FTPClient.ValidateTransfer()
EnterpriseDT.Net.Ftp.FTPClient.Get(String remoteFile)
Hotels.Hotelbeds.BLL.FTPManager.GetFtpArchiveStream(String ftpFilePath, Byte[]& buffer, String& message)

I use it in passive mode, I also tried active mode.
I use host address as ftp.someting.com I also tried directly with the IP address but still having the same error.

Any idea ?
Thanks
Aykut
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Thu Apr 15, 2010 3:40 am

Could you translate the error message to English for us?
Next

Who is online

Users browsing this forum: No registered users and 24 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign
cron