Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a FTP server and while doing testing I found an odd issue that I don't understand. I send a RETR command on file "/Folder1/file.txt" and it works fine. Then I send a RETR command on file "/Folder1/SubFolder1/file.txt" and it times out on transfering the data to the client. This was in active mode. When I switch to passive mode it works fine.

I understand the difference between the two modes, but what I don't understand is why it worked for one file in active mode, but not the other. I tried it a dozen times and still got the same results.

Any ideas? Thanks!

share|improve this question

migrated from stackoverflow.com Apr 19 '10 at 19:12

This question came from our site for professional and enthusiast programmers.

    
It must be a configuration issue with your FTP server –  Romain Hippeau Apr 19 '10 at 18:29
    
That's what I'm thinking but I don't know what configuration would cause that... –  Dan Apr 19 '10 at 18:31
    
Which server are you using ?, which platform ? –  Romain Hippeau Apr 19 '10 at 18:35
    
It's a server called CrushFTP running on Windows Server 2003 R2. –  Dan Apr 19 '10 at 19:01
1  
Not sure why this is tagged as both ftp and sftp. They are two completely separate protocols. –  Zoredache Apr 19 '10 at 19:40

3 Answers 3

If you check the official specification of the File Transfer Protocol, you'll find that:

FTP can be run in active mode or passive mode, which control how the second connection is opened. In active mode the client sends the server the IP address port number that the client will use for the data connection, and the server opens the connection. Passive mode was devised for use where the client is behind a firewall and unable to accept incoming TCP connections. The server sends the client an IP address and port number and the client opens the connection to the server. Both modes were updated in September 1998 to add support for IPv6 and made some other changes to passive mode, making it extended passive mode.

So, my first thought is that there's something wrong with your folder permissions. Double check them.

share|improve this answer
    
Folder permissions are all the same... –  Dan Apr 19 '10 at 19:06
    
Based on this suggestion, I would start by disabling the IPv6 protocol on your server so that the IPv6 stuff isnt a factor. –  djangofan Apr 19 '10 at 22:03

I'm guessing that the first file was small enough to be acceptable to transfer on the same connection, but that the second file was larger.

share|improve this answer

Although unlikely in this case another conceivable problem you may have is your client's firewall. Active FTP requires that the client open a TCP port to which the server connects for file transfer.

It is possible that the client's firewall has one extended port accessible but no more so the first file is allowed through that first port and not through any other extended ports (clients tend to allocate TCP ports in an incremental fashion).

Now with passive FTP the server allocates the TCP ports for transfer and the client connects to the server. In this case the client firewall can no longer cause much trouble because the client is connecting to the outside world (firewalls protect the outside world from connecting to within the firewall).

Almost always I find that switching from a broken active mode to a working passive mode indicates firewall problems.

Now for a diagram:


Active FTP

  client:n ---RETR portnum1---> server:21
  client:portnum1 <---fetches-- server:m1

  client:n ---RETR portnum2---> server:21
  client:portnum2 <---fetches-- server:m2

Passive FTP

  client:n ---PASV request----> server:21
  client:n <--PORT portnum1---- server:21
  client:n2 --fetches---------> server:portnum1

  client:n ---PASV request----> server:21
  client:n <--PORT portnum2---- server:21
  client:n3 --fetches---------> server:portnum2

Note that port 21 is the command channel. This is where instructions get sent to/from. Other ports are used for actual data transfer.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.