Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
6.3k views
in .NET FTP by (240 points)
Hello,

Im using the trial version of the edtftpnet CF and planning to buy the license, but i have some problems.

I made a simple example where i connect to my ftp server... its ok, then i try to download some files.. like this...

ftpConn.DownloadFile("Temp", "file1");
ftpConn.DownloadFile("Temp", "file2");
ftpConn.DownloadFile("Temp", "file3");
ftpConn.DownloadFile("Temp", "file4");
ftpConn.DownloadFile("Temp", "file5");...

during the morning he make all the downloads... but during the afternoon he make the download of the 1st file and when he tries the second one he throw a exceptcion Timeout.. here is the complete code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using EnterpriseDT.CF;
using EnterpriseDT.Net.Ftp;
using EnterpriseDT.Util.License;

namespace TesteFTP
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public ExFTPConnection ftpConn = new ExFTPConnection();
        public LicenseProperties prop;

        private void button3_Click(object sender, EventArgs e)
        {
            ftpConn.LicenseOwner = "trialuser";
            ftpConn.LicenseKey = "703-1811-5349-4362";
            
            ftpConn.ServerAddress = "the server";
            ftpConn.UserName = "my user name";
            ftpConn.Password = "my pass";
            ftpConn.ServerPort = 21;
            ftpConn.AutoLogin = true;
            //ftpConn.ConnectMode = FTPConnectMode.ACTIVE;

            try
            {
                if (!ftpConn.IsConnected)
                    ftpConn.Connect();

                ftpConn.ChangeWorkingDirectory("my dir");
            }
            catch (Exception exc) 
            {
                MessageBox.Show("N

6 Answers

0 votes
by (162k points)
Please note that IsConnected isn't that much use, especially with a CE device. You are better off not using it, and just connecting and disconnecting when required (and not keeping a connection open unnecessarily).

Active mode is where the server connects to your device for transfers and listings - are you sure that the server is able to do that, i.e. no firewall or anything preventing the server from making a socket connection to your device?

Timeouts are generally the result of 1) a firewall or 2) larger transfers where the server times out the FTP connection and disconnects you.
0 votes
by (240 points)
At my real program i only connect when im going to do an upload or download and then disconnect, this was just to test the download at the device, i tested at both device and emulator and its kind of weird because at the emulator the problem occur at the upload and download goes fine, and at the device the download give me a timeout and upload works fine.

Yes, the server is able to do Active, because we have palm applications and they connect at ftp in active mode.

And the largest file size im trying to download have like 46 kb.

here is the log for the passive mode:
DEBUG [ExFTPClient] 5 mar 2009 14:19:53.000 : Connecting to 200.171.232.79:21
DEBUG [HostNameResolver] 5 mar 2009 14:19:53.000 : 200.171.232.79 resolved to 200.171.232.79
DEBUG [ExFTPControlSocket] 5 mar 2009 14:19:53.000 : Connecting directly to ftp-server 200.171.232.79:21
DEBUG [FTPControlSocket] 5 mar 2009 14:19:54.000 : Setting socket timeout=120000
DEBUG [FTPControlSocket] 5 mar 2009 14:19:54.000 : Command encoding=System.Text.ASCIIEncoding
DEBUG [ExFTPControlSocket] 5 mar 2009 14:19:54.000 : Created control-socket: SocksContext=, ProxySettings=NoProxy, RemoteHost=200.171.232.79, controlPort=21, timeout=120000
DEBUG [FTPControlSocket] 5 mar 2009 14:19:54.000 : StrictReturnCodes=False
DEBUG [FTPControlSocket] 5 mar 2009 14:19:54.000 : 220 Microsoft FTP Service
DEBUG [FTPConnection] 5 mar 2009 14:19:54.000 : Connected to 200.171.232.79
DEBUG [FTPControlSocket] 5 mar 2009 14:19:54.000 : ---> USER usuarioftp
DEBUG [ExFTPConnection] 5 mar 2009 14:19:55.000 : Starting KeepAlive thread with period 30s
DEBUG [FTPControlSocket] 5 mar 2009 14:19:55.000 : 331 Password required for usuarioftp.
DEBUG [FTPControlSocket] 5 mar 2009 14:19:55.000 : ---> PASS ********
DEBUG [FTPControlSocket] 5 mar 2009 14:19:55.000 : 230 User usuarioftp logged in.
DEBUG [FTPConnection] 5 mar 2009 14:19:55.000 : Successfully logged in
DEBUG [FTPControlSocket] 5 mar 2009 14:19:55.000 : ---> TYPE I
DEBUG [FTPControlSocket] 5 mar 2009 14:19:55.000 : 200 Type set to I.
DEBUG [FTPControlSocket] 5 mar 2009 14:19:55.000 : ---> PWD
DEBUG [FTPControlSocket] 5 mar 2009 14:19:55.000 : 257 "/" is current directory.
DEBUG [FTPControlSocket] 5 mar 2009 14:19:55.000 : ---> CWD renan/ober
DEBUG [FTPControlSocket] 5 mar 2009 14:19:55.000 : 250 CWD command successful.
DEBUG [FTPControlSocket] 5 mar 2009 14:19:55.000 : ---> PWD
DEBUG [FTPControlSocket] 5 mar 2009 14:19:55.000 : 257 "/renan/ober" is current directory.
DEBUG [ExFTPConnection] 5 mar 2009 14:20:04.000 : Attempt #1
DEBUG [FTPConnection] 5 mar 2009 14:20:04.000 : DownloadFile(Temp,clientes.pet)
DEBUG [FTPClient] 5 mar 2009 14:20:04.000 : Setting local path to Temp\clientes.pet
DEBUG [FTPControlSocket] 5 mar 2009 14:20:04.000 : ---> PASV
DEBUG [FTPControlSocket] 5 mar 2009 14:20:04.000 : 227 Entering Passive Mode (200,171,232,79,188,186)
DEBUG [FTPControlSocket] 5 mar 2009 14:20:04.000 : Server supplied address=200.171.232.79
DEBUG [FTPControlSocket] 5 mar 2009 14:20:04.000 : Server supplied port=48314
DEBUG [FTPControlSocket] 5 mar 2009 14:20:04.000 : Substituting server supplied IP (200.171.232.79) with remote host IP (200.171.232.79)
DEBUG [ExFTPControlSocket] 5 mar 2009 14:20:04.000 : NewPassiveDataSocket(200.171.232.79,48314)
DEBUG [ExFTPControlSocket] 5 mar 2009 14:20:04.000 : Connecting directly to ftp-server 200.171.232.79:48314
DEBUG [ExFTPPassiveDataSocket] 5 mar 2009 14:20:04.000 : Created passive data-socket: ProxyConnector=
DEBUG [FTPControlSocket] 5 mar 2009 14:20:04.000 : ---> RETR clientes.pet
DEBUG [FTPControlSocket] 5 mar 2009 14:20:05.000 : 125 Data connection already open; Transfer starting.
DEBUG [FTPClient] 5 mar 2009 14:20:05.000 : Transferred 7458 bytes from remote host
DEBUG [FTPControlSocket] 5 mar 2009 14:20:05.000 : 226 Transfer complete.
DEBUG [ExFTPConnection] 5 mar 2009 14:20:07.000 : Attempt #1
DEBUG [FTPConnection] 5 mar 2009 14:20:07.000 : DownloadFile(Temp,despesas.pep)
DEBUG [FTPClient] 5 mar 2009 14:20:07.000 : Setting local path to Temp\despesas.pep
DEBUG [FTPControlSocket] 5 mar 2009 14:20:07.000 : ---> PASV
DEBUG [FTPControlSocket] 5 mar 2009 14:20:07.000 : 227 Entering Passive Mode (200,171,232,79,188,188)
DEBUG [FTPControlSocket] 5 mar 2009 14:20:07.000 : Server supplied address=200.171.232.79
DEBUG [FTPControlSocket] 5 mar 2009 14:20:07.000 : Server supplied port=48316
DEBUG [FTPControlSocket] 5 mar 2009 14:20:07.000 : Substituting server supplied IP (200.171.232.79) with remote host IP (200.171.232.79)
DEBUG [ExFTPControlSocket] 5 mar 2009 14:20:07.000 : NewPassiveDataSocket(200.171.232.79,48316)
DEBUG [ExFTPControlSocket] 5 mar 2009 14:20:07.000 : Connecting directly to ftp-server 200.171.232.79:48316
ERROR [ExFTPControlSocket] 5 mar 2009 14:20:09.000 : Failed to create connecting socket : System.Net.Sockets.SocketException: N
0 votes
by (162k points)
The only real clue here is "Failed to create connecting socket : System.Net.Sockets.SocketException: N
0 votes
by (240 points)
"Failed to create connecting socket : System.Net.Sockets.SocketException : Can not display an error message because it was not possible
to find the set of modules (assembly) of optional features "

but the erros is for passive mode.
0 votes
by (162k points)
"Failed to create connecting socket" is the key here - the relevant line of code is:

sock.Connect(ipe);

where ipe is the endpoint.

Either a firewall is blocking the connection attempt to 200.171.232.79 on port 48316, or the server isn't listening on that port (or the IP address of your device is being blocked by the server).

It is worth taking a look at the server logs to see if there's anything relevant.

Have you got another FTP program on your device that you can run to compare what's happening in active and passive mode?
0 votes
by (240 points)
Theres nothing really relevant at the servers log.

Actually i downloaded a ftp client for pocket pc just to test and in passive mode i did some thing but couldnt do a lot of downloads, and in active mode he does not even connect..

Categories

...