Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Net::FTP and

by amphiplex (Monk)
on Jul 17, 2002 at 11:08 UTC ( [id://182384]=note: print w/replies, xml ) Need Help??


in reply to Net::FTP and 'Illegal PORT command'

I would recommend turning up the Debug-Volume, this should give you and us valuable information.

---- amphiplex

Replies are listed 'Best First'.
Re: Re: Net::FTP and
by Bukowski (Deacon) on Jul 17, 2002 at 11:13 UTC
    OK with DEBUG set to 1 the relevant output is:

    Net::FTP=GLOB(0x82456bc)<<< 220 ProFTPD 1.2.4 Server (ProFTPD Human Ge +nome Project Server) [hgw3] Net::FTP=GLOB(0x82456bc)>>> user anonymous Net::FTP=GLOB(0x82456bc)<<< 331 Anonymous login ok, send your complete + email address as your password. Net::FTP=GLOB(0x82456bc)>>> PASS .... Net::FTP=GLOB(0x82456bc)<<< 230- Net::FTP=GLOB(0x82456bc)<<< Net::FTP=GLOB(0x82456bc)<<< This is the UCSC Genome Project ftp site. Net::FTP=GLOB(0x82456bc)<<< All transactions are logged. Net::FTP=GLOB(0x82456bc)<<< Net::FTP=GLOB(0x82456bc)<<< 230 Anonymous access granted, restrictions + apply. Net::FTP=GLOB(0x82456bc)>>> CWD /goldenPath/05apr2002/chromosomes/ Net::FTP=GLOB(0x82456bc)<<< 250-This directory contains the NCBI assem +bled sequence for the Net::FTP=GLOB(0x82456bc)<<< April 5, 2002 Genbank freeze in separate +files for each Net::FTP=GLOB(0x82456bc)<<< chromosome in a zipped Fasta format. Net::FTP=GLOB(0x82456bc)<<< 250 CWD command successful. Net::FTP=GLOB(0x82456bc)>>> PASV Net::FTP=GLOB(0x82456bc)<<< 227 Entering Passive Mode (128,114,50,183, +199,10). Net::FTP=GLOB(0x82456bc)>>> PORT 192,168,1,125,172,80 Net::FTP=GLOB(0x82456bc)<<< 500 Illegal PORT command. get(chr5.zip) failed: 500: Illegal PORT command. Net::FTP=GLOB(0x82456bc)>>> QUIT Net::FTP=GLOB(0x82456bc)<<< 221 Goodbye.
    The same chunk from the SunOS machine:

    Net::FTP=GLOB(0xfcd34)<<< 220 ProFTPD 1.2.4 Server (ProFTPD Human Geno +me Project Server) [hgw5] Net::FTP=GLOB(0xfcd34)>>> user anonymous Net::FTP=GLOB(0xfcd34)<<< 331 Anonymous login ok, send your complete e +mail address as your password. Net::FTP=GLOB(0xfcd34)>>> PASS .... Net::FTP=GLOB(0xfcd34)<<< 230- Net::FTP=GLOB(0xfcd34)<<< Net::FTP=GLOB(0xfcd34)<<< This is the UCSC Genome Project ftp site. Net::FTP=GLOB(0xfcd34)<<< All transactions are logged. Net::FTP=GLOB(0xfcd34)<<< Net::FTP=GLOB(0xfcd34)<<< 230 Anonymous access granted, restrictions a +pply. Net::FTP=GLOB(0xfcd34)>>> CWD /goldenPath/05apr2002/chromosomes/ Net::FTP=GLOB(0xfcd34)<<< 250-This directory contains the NCBI assembl +ed sequence for the Net::FTP=GLOB(0xfcd34)<<< April 5, 2002 Genbank freeze in separate fi +les for each Net::FTP=GLOB(0xfcd34)<<< chromosome in a zipped Fasta format. Net::FTP=GLOB(0xfcd34)<<< 250 CWD command successful. Net::FTP=GLOB(0xfcd34)>>> PASV Net::FTP=GLOB(0xfcd34)<<< 227 Entering Passive Mode (128,114,50,185,21 +6,226). Net::FTP=GLOB(0xfcd34)>>> PASV Net::FTP=GLOB(0xfcd34)<<< 227 Entering Passive Mode (128,114,50,185,21 +6,227). Net::FTP=GLOB(0xfcd34)>>> RETR chr5.zip Net::FTP=GLOB(0xfcd34)<<< 150 Opening ASCII mode data connection for c +hr5.zip (59604544 bytes).

    Two PASV commands?

    Bukowski - aka Dan (dcs@black.hole-in-the.net)
    "Coffee for the mind, Pizza for the body, Sushi for the soul" -Userfriendly

      I guess that setting
      Passive=>1
      when creating the ftp object should fix your problem. At least it did for me.

      If it works, could someone explain why exactly ?

      ---- amphiplex
        I've covered this previously for a couple of others experiencing the same problem - When connecting to a FTP server, two socket streams are used for communications - The first is the control connection initiated by your FTP client between which the FTP client and server exchange commands and replies (TCP socket 21). The second is a full-duplex connection over which data is transferred in a specified mode and type. The data transferred may be part of a file, an entire file or a listing of files within a directory. Typically, this data port is the port adjacent to the control port (TCP socket 20). In general, it is the FTP server's responsibility to initiate and maintain the data connection.

        According to the output supplied, it appears that the poster of this question is attempting to connect to the FTP from a machine with a private class address - This host address, along with the preferred socket for data communications, are sent to the server via the PORT command. I would suspect that the poster is connecting to the FTP server host through a network firewall or layer of address translation and as such, the data connection from the server to your machine is failing because the FTP server is unable to reach your private machine.

        The means by which to fix this is to switch to passive FTP transfer mode via the PASV command - This command changes the default behaviour of data port negotiation, shifting the onus for responsibility for data port establishment and maintenance back to the client. This allows the client to control its only data connection through the network firewall or translation layer, allowing normal FTP communications to occur. eg.

        use Net::FTP; # Passive mode can be set with object initiation my $ftp = Net::FTP->new( $hostname, Debug => 1, Passive => 1 ) or die +$!; $ftp->login( $user, $password ); # Or with $object->pasv; $ftp->pasv;

        Further information on this topic can be found in RFC documents File Transfer Protocol, Requirements for Internet hosts - communication layers and Firewall-Friendly FTP.

         

        Amphiplex, respect. I will ++ this tomorrow and yes :

        $ftp = Net::FTP->new($destination, Debug => 1, Passive =>1) || die "Co +uldn't connect! $!\n";

        does indeed fix the problem under Linux.

        Bukowski - aka Dan (dcs@black.hole-in-the.net)
        "Coffee for the mind, Pizza for the body, Sushi for the soul" -Userfriendly

      Net::FTP=GLOB(0x82456bc)>>> PORT 192,168,1,125,172,80

      I think the error is here, you can't use a private address for the PORT command...

      Ciao, Valerio

      You get the error because the PORT command is following a PASV command. They should not happen together.

      You chopped off the top of the dubug output, what version of Net::FTP do you have installed ?

      As someone else noticed you have a private IP, is the server on the other side of a firewall ?

      If yes, you must use passive mode, as the remote server will not be able to connect back to you. But that is a different problem.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://182384]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-19 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found