I am running code as a windows service. When I run the same code in debug mode it works, when i run the code as a service I get the error "Cannot read from a directory ('/')". I narrowed the command down to FTP.GetFiles method. In the FTP directory there are 81 files with the largest being 110k in size. I have used the rebex.filelogwriter with the log level set to debug. I have tried using pasv mode and active mode but receive the same error. Here is the Rebex Log. I have removed the user and ipaddress from the file. Thank you for any help you can provide.

2010-21-06 08:10:01.046 Opening log file.
2010-21-06 08:10:01.046 INFO Ftp(2) Info: Connecting to ##FTP:PORT## using Ftp 3.0.3588.0.
2010-21-06 08:10:01.046 INFO Ftp(2) Info: Using proxy none.
2010-21-06 08:10:01.234 DEBUG Ftp(2) Info: Connection succeeded.
2010-21-06 08:10:01.437 INFO Ftp(2) Response: 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
2010-21-06 08:10:01.437 INFO Ftp(2) Response: 220-You are user number 5 of 250 allowed.
2010-21-06 08:10:01.437 INFO Ftp(2) Response: 220-<<
2010-21-06 08:10:01.437 INFO Ftp(2) Command: FEAT
2010-21-06 08:10:01.640 INFO Ftp(2) Response: 211-Extensions supported:
2010-21-06 08:10:01.640 INFO Ftp(2) Response:  EPRT
2010-21-06 08:10:01.640 INFO Ftp(2) Response:  IDLE
2010-21-06 08:10:01.640 INFO Ftp(2) Response:  MDTM
2010-21-06 08:10:01.640 INFO Ftp(2) Response:  SIZE
2010-21-06 08:10:01.640 INFO Ftp(2) Response:  REST STREAM
2010-21-06 08:10:01.640 INFO Ftp(2) Response:  MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
2010-21-06 08:10:01.640 INFO Ftp(2) Response:  MLSD
2010-21-06 08:10:01.640 INFO Ftp(2) Response:  ESTP
2010-21-06 08:10:01.640 INFO Ftp(2) Response:  PASV
2010-21-06 08:10:01.640 INFO Ftp(2) Response:  EPSV
2010-21-06 08:10:01.640 INFO Ftp(2) Response:  SPSV
2010-21-06 08:10:01.640 INFO Ftp(2) Response:  ESTA
2010-21-06 08:10:01.640 INFO Ftp(2) Response:  AUTH TLS
2010-21-06 08:10:01.640 INFO Ftp(2) Response:  PBSZ
2010-21-06 08:10:01.640 INFO Ftp(2) Response:  PROT
2010-21-06 08:10:01.640 INFO Ftp(2) Response:  UTF8
2010-21-06 08:10:01.640 INFO Ftp(2) Response: 211 End.
2010-21-06 08:10:01.640 INFO Ftp(2) Command: USER ##
2010-21-06 08:10:01.828 INFO Ftp(2) Response: 331 User ## OK. Password required
2010-21-06 08:10:01.828 INFO Ftp(2) Command: PASS **********
2010-21-06 08:10:02.031 INFO Ftp(2) Response: 230-Your bandwidth usage is restricted
2010-21-06 08:10:02.031 INFO Ftp(2) Response: 230-User ## has group access to:  ftpgroup
2010-21-06 08:10:02.031 INFO Ftp(2) Response: 230 OK. Current restricted directory is /
2010-21-06 08:10:02.031 INFO Ftp(2) Command: OPTS UTF8 ON
2010-21-06 08:10:02.234 INFO Ftp(2) Response: 200 OK, UTF-8 enabled
2010-21-06 08:10:02.234 DEBUG Ftp(2) Info: Starting data transfer.
2010-21-06 08:10:02.234 INFO Ftp(2) Command: TYPE I
2010-21-06 08:10:02.625 INFO Ftp(2) Response: 200 TYPE is now 8-bit binary
2010-21-06 08:10:02.625 INFO Ftp(2) Command: PASV
2010-21-06 08:10:02.828 INFO Ftp(2) Response: 227 Entering Passive Mode (##IPADDRESS##)
2010-21-06 08:10:02.828 DEBUG Ftp(2) Info: Establishing data connection to ##IPADDRESS##.
2010-21-06 08:10:23.859 DEBUG Ftp(2) Info: Error while starting data transfer: Rebex.Net.FtpException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> Rebex.Net.ProxySocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> Rebex.Net.ProxySocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at 328075837.13357030529.151169660(String , IPAddress , Int32 )
   --- End of inner exception stack trace ---
   at 328075837.13357030529.151169660(String , IPAddress , Int32 )
   --- End of inner exception stack trace ---
   at 328075837.13357030529.362804169(IAsyncResult , String )
   at 328075837.13357030529.15613119759(IAsyncResult , Int32 )
   at Rebex.Net.ProxySocket.EndConnect(IAsyncResult asyncResult)
   at 328075837.588172452.151169660(EndPoint )
   --- End of inner exception stack trace ---
   at 328075837.588172452.151169660(EndPoint )
   at Rebex.Net.Ftp.19941338139(String , 588172452 , Int64 , FtpTransferState )
2010-21-06 08:10:23.859 DEBUG Ftp(2) Info: Closing data connection.
2010-21-06 08:10:23.859 ERROR Ftp(2) Info: Rebex.Net.FtpBatchTransferException: Cannot read from a directory ('/'). ---> Rebex.Net.FtpException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> Rebex.Net.ProxySocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> Rebex.Net.ProxySocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at 328075837.13357030529.151169660(String , IPAddress , Int32 )
   --- End of inner exception stack trace ---
   at 328075837.13357030529.151169660(String , IPAddress , Int32 )
   --- End of inner exception stack trace ---
   at 328075837.13357030529.362804169(IAsyncResult , String )
   at 328075837.13357030529.15613119759(IAsyncResult , Int32 )
   at Rebex.Net.ProxySocket.EndConnect(IAsyncResult asyncResult)
   at 328075837.588172452.151169660(EndPoint )
   --- End of inner exception stack trace ---
   at 328075837.588172452.151169660(EndPoint )
   at Rebex.Net.Ftp.19941338139(String , 588172452 , Int64 , FtpTransferState )
   at Rebex.Net.Ftp.8956377289(String , Stream , Int64 )
   at Rebex.Net.Ftp.GetList(String arguments)
   at 328075837.20961014519.1569771334(String )
   at 328075837.20961014519.AppendRemoteFileList(ArrayList dirs, ArrayList files, 792810434 remotePathDesc, Regex nameFilter, Boolean appendDirs, String remotePath, String localPath)
   at 328075837.17759126019.17005970309(792810434 )
   --- End of inner exception stack trace ---
   at 328075837.17759126019.HandleException(Exception ex, 2061242560 type, String remotePath, String localPath, 2074704321 remoteInfo, 2074704321 localInfo, 16902977159 defaultAction, 16902977159 possibleActions, 16902977159& chosenAction)
   at 328075837.17759126019.HandleCaughtException(Exception caught, String message, 2061242560 type, String remotePath, String localPath, 2074704321 remoteInfo, 2074704321 localInfo, 16902977159 possibleActions, 16902977159& chosenAction)
   at 328075837.17759126019.17005970309(792810434 )
   at 328075837.17759126019.5474409839(String , String )
   at 328075837.17759126019.TransferFiles(Boolean putFile, Object expectedRootItem, String localPath, String remotePath, 1286277555 transferOptions, 2117658205 existingFileMode)
   at Rebex.Net.Ftp.GetFiles(String remotePath, String localDirectoryPath, FtpBatchTransferOptions transferOptions, FtpActionOnExistingFiles existingFileMode)
2010-21-06 08:10:23.859 INFO Ftp(2) Command: QUIT
2010-21-06 08:10:24.031 INFO Ftp(2) Response: 221-Goodbye. You uploaded 0 and downloaded 0 kbytes.
2010-21-06 08:10:24.031 INFO Ftp(2) Response: 221 Logout.

asked 21 Jun '10, 15:30

Jonathan's gravatar image

Jonathan
16
accept rate: 0%

edited 10 Aug '10, 13:03

Rebex%20KB's gravatar image

Rebex KB ♦♦
256312

I changed the formatting of the log to make it a bit more readable.

(21 Jun '10, 15:59) Lukas Pokorny ♦♦

The topmost exception message is misleading (this will be fixed for the next release) - what happened is that the connection attempt failed while establishing a data connection.

In FTP's passive mode, data connection is established by connecting to the IP address/port specified by the server in response to PASV command. Sometimes, misconfigured FTP servers or firewalls transmit a different IP address than desired (for example, an IP address in FTP server's local network), which makes the process of establishing the data connection somewhat complicated.

Rebex FTP has a built-in workaround for this issue, but perhaps it was not applied in this case for some reason (hard to tell with no knowledge of your IP addresses). Try explicitly forcing this workaround using the following FTP option:

C#:

ftp.Options |= FtpOptions.IgnorePassiveModeAddress;

VB.NET

ftp.Options = Ftp.Options Or FtpOptions.IgnorePassiveModeAddress

(where "ftp" is an instance of Ftp object)


If this doesn't help, try enabling one more option:

C#:

ftp.Options |= FtpOptions.ConnectPassiveLater;

VB.NET

ftp.Options = Ftp.Options Or FtpOptions.ConnectPassiveLater;

This changes the method of establishing the data connection slightly - it causes it to be initialized only after the LIST/NLST/RETR/STOR command has been sent.


If none of this helps - are you able to connect using any third-party FTP client, such as FileZilla? If you are, please send us its communication log to support@rebex.net, we should be able to tell what it did differently and provide instructions for reproducing the same behavior with Rebex FTP.

link

answered 21 Jun '10, 16:12

Lukas%20Pokorny's gravatar image

Lukas Pokorny ♦♦
2.2k18
accept rate: 32%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×136
×18
×11
×6

Asked: 21 Jun '10, 15:30

Seen: 708 times

Last updated: 23 Mar '11, 04:22