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)
using EnterpriseDT.Util.Debug;
...
Logger.CurrentLevel = Level.ALL;
Logger.AddAppender(new FileAppender("mylog.txt"));
0 votes
by (440 points)
DEBUG [HostNameResolver] 23 May 2008 08:53:36.062 : robo.org.net resolved to 123.221.340.249
DEBUG [FTPClient] 23 May 2008 08:53:36.062 : Connecting to 122.122.343.249:51
DEBUG [FTPControlSocket] 23 May 2008 08:53:36.390 : 220 Microsoft FTP Service
DEBUG [FTPControlSocket] 23 May 2008 08:53:36.390 : ---> USER praveen
DEBUG [FTPControlSocket] 23 May 2008 08:53:36.546 : 331 Password required for praveen.
DEBUG [FTPControlSocket] 23 May 2008 08:53:36.546 : ---> PASS ********
DEBUG [FTPControlSocket] 23 May 2008 08:53:36.718 : 230 User praveen logged in.
DEBUG [FTPConnection] 23 May 2008 08:53:36.718 : Successfully logged in
DEBUG [FTPControlSocket] 23 May 2008 08:53:36.718 : ---> TYPE I
DEBUG [FTPControlSocket] 23 May 2008 08:53:36.875 : 200 Type set to I.
DEBUG [FTPControlSocket] 23 May 2008 08:53:36.875 : ---> PWD
DEBUG [FTPControlSocket] 23 May 2008 08:53:37.031 : 257 "/praveen" is current directory.
DEBUG [FTPControlSocket] 23 May 2008 08:53:37.031 : ---> CWD /praveen
DEBUG [FTPControlSocket] 23 May 2008 08:53:37.203 : 250 CWD command successful.
DEBUG [FTPControlSocket] 23 May 2008 08:53:37.203 : ---> PWD
DEBUG [FTPControlSocket] 23 May 2008 08:53:37.359 : 257 "/praveen" is current directory.
DEBUG [FTPControlSocket] 23 May 2008 08:53:37.359 : ---> CWD DataCubes
DEBUG [FTPControlSocket] 23 May 2008 08:53:37.515 : 250 CWD command successful.
DEBUG [FTPControlSocket] 23 May 2008 08:53:37.515 : ---> PWD
DEBUG [FTPControlSocket] 23 May 2008 08:53:37.687 : 257 "/praveen/DataCubes" is current directory.
DEBUG [FTPControlSocket] 23 May 2008 08:53:37.687 : ---> TYPE I
DEBUG [FTPControlSocket] 23 May 2008 08:53:37.843 : 200 Type set to I.
DEBUG [FTPControlSocket] 23 May 2008 08:53:37.843 : ---> PASV
DEBUG [FTPControlSocket] 23 May 2008 08:53:38.015 : 227 Entering Passive Mode (128,121,240,249,19,7).
DEBUG [FTPControlSocket] 23 May 2008 08:53:38.015 : Server supplied address=123.221.340.249
DEBUG [FTPControlSocket] 23 May 2008 08:53:38.015 : Server supplied port=4871
DEBUG [FTPControlSocket] 23 May 2008 08:53:38.015 : Substituting server supplied IP (123.221.340.249) with remote host IP (123.221.340.249)
DEBUG [FTPControlSocket] 23 May 2008 08:53:38.015 : NewPassiveDataSocket(123.221.340.249,4871)
DEBUG [FTPControlSocket] 23 May 2008 08:53:38.171 : ---> STOR SectionVisits_2224.cub
DEBUG [FTPControlSocket] 23 May 2008 08:53:38.343 : 125 Data connection already open; Transfer starting.
ALL [FTPConnection] 23 May 2008 08:53:38.343 : Invoking delegate EnterpriseDT.Net.Ftp.BytesTransferredHandler -> DCube.Ftp._ftpConnection_BytesTransferred
ALL [FTPConnection] 23 May 2008 08:53:38.343 : Finding MainWindowHandle
ALL [FTPConnection] 23 May 2008 08:53:39.359 : Error while getting GUI control : System.InvalidOperationException: Process performance counter is disabled, so the requested operation cannot be performed.
System.InvalidOperationException: Process performance counter is disabled, so the requested operation cannot be performed.
at System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib library)
at System.Diagnostics.NtProcessManager.GetProcessInfos(String machineName, Boolean isRemoteMachine)
at System.Diagnostics.ProcessManager.GetProcessInfos(String machineName)
at System.Diagnostics.Process.EnsureState(State state)
at System.Diagnostics.Process.get_MainWindowHandle()
at EnterpriseDT.Net.Ftp.FTPConnection.InvokeDelegate(Boolean preferGuiThread, Boolean permitAsync, Delegate del, Object[] args)
ALL [FTPConnection] 23 May 2008 08:53:39.375 : No GUI control
ALL [FTPConnection] 23 May 2008 08:53:39.375 : Invoking delegate dynamically
ALL [FTPConnection] 23 May 2008 08:53:39.375 : Dynamic delegate invocation complete
ALL [FTPConnection] 23 May 2008 08:53:39.375 : Invoking delegate EnterpriseDT.Net.Ftp.BytesTransferredHandler -> DCube.Ftp._ftpConnection_BytesTransferred
ALL [FTPConnection] 23 May 2008 08:53:39.375 : No GUI control
ALL [FTPConnection] 23 May 2008 08:53:39.375 : Invoking delegate dynamically
ALL [FTPConnection] 23 May 2008 08:53:39.375 : Dynamic delegate invocation complete
ALL [FTPConnection] 23 May 2008 08:53:39.375 : Invoking delegate EnterpriseDT.Net.Ftp.BytesTransferredHandler -> DCube.Ftp._ftpConnection_BytesTransferred
ALL [FTPConnection] 23 May 2008 08:53:39.375 : No GUI control
ALL [FTPConnection] 23 May 2008 08:53:39.375 : Invoking delegate dynamically
ALL [FTPConnection] 23 May 2008 08:53:39.375 : Dynamic delegate invocation complete
ALL [FTPConnection] 23 May 2008 08:53:39.531 : Invoking delegate EnterpriseDT.Net.Ftp.BytesTransferredHandler -> DCube.Ftp._ftpConnection_BytesTransferred
ALL [FTPConnection] 23 May 2008 08:53:39.531 : No GUI control
ALL [FTPConnection] 23 May 2008 08:53:39.531 : Invoking delegate dynamically
ALL [FTPConnection] 23 May 2008 08:53:39.531 : Dynamic delegate invocation complete
ALL [FTPConnection] 23 May 2008 08:53:39.703 : Invoking delegate EnterpriseDT.Net.Ftp.BytesTransferredHandler -> DCube.Ftp._ftpConnection_BytesTransferred
ALL [FTPConnection] 23 May 2008 08:55:59.359 : No GUI control
ALL [FTPConnection] 23 May 2008 08:55:59.359 : Invoking delegate dynamically
ALL [FTPConnection] 23 May 2008 08:55:59.359 : Dynamic delegate invocation complete
DEBUG [FTPClient] 23 May 2008 08:55:59.359 : Closing source stream
ALL [FTPConnection] 23 May 2008 08:55:59.515 : Invoking delegate EnterpriseDT.Net.Ftp.BytesTransferredHandler -> DCube.Ftp._ftpConnection_BytesTransferred
ALL [FTPConnection] 23 May 2008 08:55:59.515 : No GUI control
ALL [FTPConnection] 23 May 2008 08:55:59.515 : Invoking delegate dynamically
ALL [FTPConnection] 23 May 2008 08:55:59.515 : Dynamic delegate invocation complete
DEBUG [FTPClient] 23 May 2008 08:55:59.515 : Transferred 8514271 bytes to remote host

The bolded bit is repating several time so I have deleted that repeating bit from the log file.
So how do we enable the Process performance counter, so the requested operation cannot be performed.

The application runs perfectly on WIN XP, but NOT on WIN 2003 server.

I have checked the registry, on XP, the Disable Performance Counters at the following location, has a zero value.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance

on the WIN 2003 server, there is no Disable Performance Counters property at the same location
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance
0 votes
by (161k points)
For one thing you've got a number of IP addresses for your server: 123.221.340.249, 122.122.343.249, and the server is returning 128.121.240.249.

Figuring out the correct one will help a lot.
0 votes
by (440 points)
Hi,

Actually I have changed the IP addresses, just was not to sure if I could post them on the public forum,
so there is no problem with the IP address.

Can you please advice how to solve thid problem.

thanks
Praveen
0 votes
by (440 points)
DEBUG [HostNameResolver] 27 May 2008 08:56:04.031 : metro.mediaonenetwork.net resolved to 128.121.240.249
DEBUG [FTPClient] 27 May 2008 08:56:04.031 : Connecting to 128.121.240.249:21
DEBUG [FTPControlSocket] 27 May 2008 08:56:04.375 : 220 Microsoft FTP Service
DEBUG [FTPControlSocket] 27 May 2008 08:56:04.375 : ---> USER m1user
DEBUG [FTPControlSocket] 27 May 2008 08:56:04.531 : 331 Password required for m1user.
DEBUG [FTPControlSocket] 27 May 2008 08:56:04.531 : ---> PASS ********
DEBUG [FTPControlSocket] 27 May 2008 08:56:04.687 : 230 User m1user logged in.
DEBUG [FTPConnection] 27 May 2008 08:56:04.687 : Successfully logged in
DEBUG [FTPControlSocket] 27 May 2008 08:56:04.687 : ---> TYPE I
DEBUG [FTPControlSocket] 27 May 2008 08:56:04.859 : 200 Type set to I.
DEBUG [FTPControlSocket] 27 May 2008 08:56:04.859 : ---> PWD
DEBUG [FTPControlSocket] 27 May 2008 08:56:05.015 : 257 "/m1user" is current directory.
DEBUG [FTPControlSocket] 27 May 2008 08:56:05.015 : ---> CWD /m1user
DEBUG [FTPControlSocket] 27 May 2008 08:56:05.187 : 250 CWD command successful.
DEBUG [FTPControlSocket] 27 May 2008 08:56:05.187 : ---> PWD
DEBUG [FTPControlSocket] 27 May 2008 08:56:05.343 : 257 "/m1user" is current directory.
DEBUG [FTPControlSocket] 27 May 2008 08:56:05.343 : ---> CWD DataCubes
DEBUG [FTPControlSocket] 27 May 2008 08:56:05.500 : 250 CWD command successful.
DEBUG [FTPControlSocket] 27 May 2008 08:56:05.500 : ---> PWD
DEBUG [FTPControlSocket] 27 May 2008 08:56:05.671 : 257 "/m1user/DataCubes" is current directory.
DEBUG [FTPControlSocket] 27 May 2008 08:56:05.671 : ---> TYPE I
DEBUG [FTPControlSocket] 27 May 2008 08:56:05.828 : 200 Type set to I.
DEBUG [FTPControlSocket] 27 May 2008 08:56:05.875 : ---> PASV
DEBUG [FTPControlSocket] 27 May 2008 08:56:06.031 : 227 Entering Passive Mode (128,121,240,249,16,253).
DEBUG [FTPControlSocket] 27 May 2008 08:56:06.031 : Server supplied address=128.121.240.249
DEBUG [FTPControlSocket] 27 May 2008 08:56:06.031 : Server supplied port=4349
DEBUG [FTPControlSocket] 27 May 2008 08:56:06.031 : Substituting server supplied IP (128.121.240.249) with remote host IP (128.121.240.249)
DEBUG [FTPControlSocket] 27 May 2008 08:56:06.031 : NewPassiveDataSocket(128.121.240.249,4349)
DEBUG [FTPControlSocket] 27 May 2008 08:56:06.187 : ---> STOR SectionVisits_2224.cub
DEBUG [FTPControlSocket] 27 May 2008 08:56:06.359 : 125 Data connection already open; Transfer starting.
DEBUG [FTPClient] 27 May 2008 08:56:08.484 : Closing source stream
DEBUG [FTPClient] 27 May 2008 08:56:08.640 : Transferred 121922 bytes to remote host
DEBUG [FTPControlSocket] 27 May 2008 08:56:08.812 : 226 Transfer complete.
DEBUG [FTPControlSocket] 27 May 2008 08:56:08.812 : ---> TYPE I
DEBUG [FTPControlSocket] 27 May 2008 08:56:08.968 : 200 Type set to I.
DEBUG [FTPControlSocket] 27 May 2008 08:56:08.984 : ---> PASV
DEBUG [FTPControlSocket] 27 May 2008 08:56:09.140 : 227 Entering Passive Mode (128,121,240,249,16,254).
DEBUG [FTPControlSocket] 27 May 2008 08:56:09.140 : Server supplied address=128.121.240.249
DEBUG [FTPControlSocket] 27 May 2008 08:56:09.140 : Server supplied port=4350
DEBUG [FTPControlSocket] 27 May 2008 08:56:09.140 : Substituting server supplied IP (128.121.240.249) with remote host IP (128.121.240.249)
DEBUG [FTPControlSocket] 27 May 2008 08:56:09.140 : NewPassiveDataSocket(128.121.240.249,4350)
DEBUG [FTPControlSocket] 27 May 2008 08:56:09.312 : ---> STOR SectionVisits_50.cub
DEBUG [FTPControlSocket] 27 May 2008 08:56:09.468 : 125 Data connection already open; Transfer starting.
DEBUG [FTPClient] 27 May 2008 08:58:28.203 : Closing source stream
DEBUG [FTPClient] 27 May 2008 08:58:28.218 : Transferred 8514271 bytes to remote host
0 votes
by (161k points)
Changing the IP addresses to differing ones wastes our time tracking down problems that don't exist. Next time just change to XXX if you are sure they are all identical.

The best thing at this point is to email your full log & and your code to support at enterprisedt dot com and we'll take a look and report back to the forum later.
0 votes
by (161k points)
It looks like this is your problem:

System.InvalidOperationException: Process performance counter is disabled

We don't really know anything about this error - take a look at this link for some advice:

http://www.dotnet247.com/247reference/m ... 55103.aspx

Perhaps you may need to remove the code that causes this exception.

Categories

...