Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
11.1k views
in .NET FTP by (440 points)
Hi,

Please find the code and the error.

_ftpConnection.Connect() FAILS

Can you please advice how to fix this problem

Thanks
Praveen

Private Sub ConnectFTP()
        Try

            'Setup ftp and connect.
            _ftpConnection.ServerAddress = Config.FtpServer
            _ftpConnection.ServerPort = Config.FtpServerPort
            _ftpConnection.UserName = Config.FtpUser
            _ftpConnection.Password = Config.FtpPassword
            'This setting is not working, the event is still firing based upon the default of 4096 bytes.
            _ftpConnection.TransferNotifyInterval = 1000

            If Config.FtpPassiveMode Then
                _ftpConnection.ConnectMode = EnterpriseDT.Net.Ftp.FTPConnectMode.PASV
            Else
                _ftpConnection.ConnectMode = EnterpriseDT.Net.Ftp.FTPConnectMode.ACTIVE
            End If

            ApplicationLog.Log("FTP Passive mode: " & Config.FtpPassiveMode)
            _ftpConnection.Connect()

            If Config.FtpFolder <> "" Then
                _ftpConnection.ChangeWorkingDirectory(Config.FtpFolder)
            End If

        Catch ex As Exception
            If _ftpConnection.IsConnected Then
                _ftpConnection.Close()
            End If
            ApplicationLog.Log(ex.ToString)

        End Try

    End Sub



The ERROR I get is:
System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at EnterpriseDT.Net.StandardSocket.Connect(EndPoint remoteEP)
   at EnterpriseDT.Net.Ftp.FTPControlSocket.ConnectSocket(BaseSocket socket, IPAddress address, Int32 port)
   at EnterpriseDT.Net.Ftp.FTPControlSocket.Initialize(BaseSocket sock, IPAddress remoteHost, Int32 controlPort, Int32 timeout)
   at EnterpriseDT.Net.Ftp.FTPControlSocket..ctor(IPAddress remoteHost, Int32 controlPort, Int32 timeout)
   at EnterpriseDT.Net.Ftp.FTPClient.Connect(IPAddress remoteAddr, Int32 controlPort, Int32 timeout)
   at EnterpriseDT.Net.Ftp.FTPClient.Connect()
   at EnterpriseDT.Net.Ftp.FTPConnection.Connect()
   at DCube.Ftp.ConnectFTP() in C:\M1Projects\DCube.root\DCube\Ftp.vb:line 37"  String

17 Answers

0 votes
by (51.1k points)
There is a mention of an error like this on the MS website (10013 on http://support.microsoft.com/kb/819124), but it's hard to see how that can be relevant to this situation since we are not specifying the port-number to use for the local machine.

Is your application running under reduced permissions such that the OS is preventing it from opening a socket?

- Hans (EnterpriseDT)
0 votes
by (440 points)
Hi,

Yes, it looks like application running under reduced permissions such that the OS is preventing it from opening a socket?

How can we set permissions for an application so that the OS will not prevent it from opening a socket.

Many thanks for your quick help.

Kind Regards
Praveen
0 votes
by (161k points)
That really depends on your application - find out what user it is running under, and give that user admin permissions to start with.
0 votes
by (440 points)
Hi,

What is the diffrence between

_ftpConnection.ConnectMode = EnterpriseDT.Net.Ftp.FTPConnectMode.PASV

and

_ftpConnection.ConnectMode = EnterpriseDT.Net.Ftp.FTPConnectMode.ACTIVE

I need to FTP atleast 25 to 30 files of less than 1mb
what do you recomend, wether to have a single connection and upload all the files
or open and close FTP connection for each file.

Thanks for your help.

Kind Regards
Praveen
0 votes
by (161k points)
Use one connection.

See http://www.enterprisedt.com/products/ed ... modes.html for more on active and passive modes.
0 votes
by (51.1k points)
Please have a look at the Developer's Guide in the section called "Active and passive modes" (in the FTP Protocol OverView).

- Hans (EnterpriseDT)
0 votes
by (440 points)
Hi,

I am able to FTP only 2 files from the 25 to 30 files I have.
the process just stops after 2 files are FTP'ed.

I have replaced edtftpnet.dll 1.2.2.0 with edtFTPnet.dll 1.2.6.0

I have tried to increase the interval from 1000 to 4000
_ftpConnection.TransferNotifyInterval = 4000

Still I am not able to FTP all the 30 files.

Please help.

Thanks
Praveen
0 votes
by (51.1k points)
Can you please enable logging (see Developer's Guide) and post a log that illustrates the error here.

- Hans (EnterpriseDT)
0 votes
by (440 points)
Hi From my system I am able to upload all the 30 files sucessfully,

but when I run the application from the server it only does 2 files.

I trying to do the logging as soon as I have I will post it.

MANY MANY thanks for your help.

Regards
Praveen
0 votes
by (440 points)
Sorry I am new to this, dont know how to enable log,
can you please post some sample code.

Thanks
Praveen

Categories

...