ayegorov has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am receiving weird error "555 Can't read command channel socket"
Cannot find this error in FTP specifications, which leads me to thought that this is this module's specific error. Here is the debug log of the connection:
Net-FTPSSL Version: 0.17 Perl: 5.008008 [5.8.8], OS: linux Server (port): XXX,XXX,XXX,XXX (21) SKT <<< 220 RBCNG FTPS (Version Wed Jan 5 14:54:38 2011) server read +y. SKT >>> AUTH TLS SKT <<< 234 Enabling TLS, awaiting negotiations. >>> USER XXXXXXX <<< 331 Password required for XXXXXXX. >>> PASS ******* <<< 230 User XXXXXXX logged in. >>> PBSZ 0 <<< 200 PBSZ Command successful. >>> PROT P <<< 200 PROT Command successful. >>> PASV <<< 227 Entering Passive Mode (XXX,XXX,XXX,XXX0,24,54) >>> LIST inbound <<< 150 Opening data connection for '/bin/ls'. <<< 226 Transfer complete. $VAR1 = 'drwxrwxr-x 2 XXXXXXX FTP 4096 Jan 5 14:04 inva +lid'; $VAR2 = 'drwxrwxr-x 2 XXXXXXX FTP 256 Jan 4 10:59 vali +d'; >>> TYPE I <<< 200 Type set to I >>> PBSZ 0 <<< 200 PBSZ Command successful. >>> PROT P <<< 200 PROT Command successful. >>> PASV <<< 227 Entering Passive Mode (XXX,XXX,XXX,XXX0,24,55) >>> HELP <<< 214- The following commands are recognized (* =>'s unimplemented). <<< USER PORT STOR MSAM* RNTO NLST MKD CDUP <<< PASS PASV APPE MRSQ* ABOR* SITE XMKD* XCUP* <<< ACCT* TYPE MLFL* MRCP* DELE SYST RMD STOU <<< SMNT* STRU MAIL* ALLO CWD STAT XRMD* SIZE <<< REIN MODE MSND* REST* XCWD* HELP PWD MDTM* <<< QUIT RETR MSOM* RNFR LIST NOOP XPWD* FEAT <<< AUTH PBSZ PROT CCC <<< 214 Direct comments to sysadm. <<+ 214 The ALLO command is supported. >>> ALLO 5 <<< 202 ALLO command ignored. >>> STOR test <<+ 555 Can't read command channel socket: >>> QUIT <<+ 555 Can't read command channel socket:
And the code itself:
use Net::FTPSSL; my ($ftps) = Net::FTPSSL->new("XXXXXXX", "Port" => 21, "Encryption" => "E", "Debug" => 1, "OverridePASV" => 0); if (!$ftps->login("XXXXX", "XXXXX")) { die($ftps->last_message()); } use Data::Dumper; print Dumper($ftps->list("folder1")), "\n"; $ftps->binary(); $ftps->put("test"); $ftps->quit();
Can you please advise me the way to resolve it?

Replies are listed 'Best First'.
Re: NET:FTPSSL, 555 Can't read command channel socket
by oko1 (Deacon) on Jan 05, 2011 at 20:45 UTC

    Easy enough to tell if it's part of the module:

    $ grep 'read command channel socket' $(perldoc -l Net::FTPSSL) ? "Can't read command channel socket: $!"

    As to handling it - the code around that line makes it relatively obvious why the message is being generated:

    # Now lets read the response from the command channel. my $read = sysread( $self, $data, 4096); unless( $read ) { # Not called as an object member in case $self not a FTPSSL +obj. _croak_or_return ($self, 0, (defined $read) ? "Can't read command channel socket: +$!" : "Unexpected EOF on command channel s +ocket!"); return (CMD_ERROR); } }

    Combined with the debug log, it looks like you're losing your connection toward the end of the transaction. What happens if you try all of the above manually?

    (I also find it rather strange that an automated interaction would invoke 'HELP'. Doesn't smell kosher to me; seems like there's some kind of odd problem happening. In any case, 'perl -d' is your friend.)

    -- 
    Education is not the filling of a pail, but the lighting of a fire.
     -- W. B. Yeats

      Seems reasonable and thanks for pointing out, where the error on the module appears.
      The recipient's ftp server seems to throw the HELP command as the reply to entering into PASV.
      I compared the output from the same script, which runs OK on old server, and on new server

      OLD server

      >>> TYPE I <<< 200 Type set to I >>> PBSZ 0 <<< 200 PBSZ Command successful. >>> PROT P <<< 200 PROT Command successful. >>> PASV <<< 227 Entering Passive Mode (XXX,XXX,XXX,XXX,23,237) >>> ALLO 5 <<< 202 ALLO command ignored. >>> STOR test <<< 150 Opening data connection for test. <<< 226 Transfer complete. >>> QUIT <<< 221 Goodbye.

      NEW server

      >>> TYPE I <<< 200 Type set to I >>> PBSZ 0 <<< 200 PBSZ Command successful. >>> PROT P <<< 200 PROT Command successful. >>> PASV <<< 227 Entering Passive Mode (XXX,XXX,XXX,XXX,23,243) >>> HELP <<< 214- The following commands are recognized (* =>'s unimplemented). <<< USER PORT STOR MSAM* RNTO NLST MKD CDUP <<< PASS PASV APPE MRSQ* ABOR* SITE XMKD* XCUP* <<< ACCT* TYPE MLFL* MRCP* DELE SYST RMD STOU <<< SMNT* STRU MAIL* ALLO CWD STAT XRMD* SIZE <<< REIN MODE MSND* REST* XCWD* HELP PWD MDTM* <<< QUIT RETR MSOM* RNFR LIST NOOP XPWD* FEAT <<< AUTH PBSZ PROT CCC <<< 214 Direct comments to sysadm. <<+ 214 The ALLO command is supported. >>> ALLO 5 <<< 202 ALLO command ignored. >>> STOR test <<+ 555 Can't read command channel socket: >>> QUIT <<+ 555 Can't read command channel socket:
      The further attempts to reveal the truth lead me to the strace output:
      open("test", O_RDONLY) = 4 ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff91df0b70) = -1 ENOTTY (I +nappropriate ioctl for device) lseek(4, 0, SEEK_CUR) = 0 fstat(4, {st_mode=S_IFREG|0777, st_size=5, ...}) = 0 fcntl(4, F_SETFD, FD_CLOEXEC) = 0 write(2, ">>> PBSZ 0\n", 11>>> PBSZ 0 ) = 11 write(3, "\27\3\1\0\30Y\334L\2637>O\211\225C\313vG\302\233\311/\354\34 +\n\375\26JH", 29) = 29 read(3, "\27\3\1\0.", 5) = 5 read(3, "|\3\256\307\305\26\3N\177\270\255\333\323\365a,\350\n9\234&\3 +52\274\316\320{\2264\301y\204\321"..., 46) = 46 write(2, "<<< 200 PBSZ Command successful."..., 33<<< 200 PBSZ Command + successful. ) = 33 write(2, ">>> PROT P\n", 11>>> PROT P ) = 11 write(3, "\27\3\1\0\30<\203,c\325/\26\211\27*\246Q6\313,F\301\251\247l +\327\227T\236", 29) = 29 read(3, "\27\3\1\0.", 5) = 5 read(3, "\316>\361\207&%\350\351z\301R\234Z\227k\257\370<k9E\267P\225\ +r\300R\6\331\374\273\227"..., 46) = 46 write(2, "<<< 200 PROT Command successful."..., 33<<< 200 PROT Command + successful. ) = 33 write(2, ">>> PASV\n", 9>>> PASV ) = 9 write(3, "\27\3\1\0\26\207\31Pp!\301R\17\31\2600\275\203\326\34\233Z\2 +1\225|\r|", 27) = 27 read(3, "\27\3\1\0A", 5) = 5 read(3, "\263+\7(\272Fi\322\356\24 ;i\246\213\374\253\346\206\23\n'\24 +4\366c\222\306wkCF\301"..., 65) = 65 write(2, "<<< 227 Entering Passive Mode (1"..., 52<<< 227 Entering Pas +sive Mode (XXX,XXX,XXX,XXX,23,212) ) = 52 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 5 ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff91df0d60) = -1 EINVAL (I +nvalid argument) lseek(5, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek) ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff91df0d60) = -1 EINVAL (I +nvalid argument) lseek(5, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek) fcntl(5, F_SETFD, FD_CLOEXEC) = 0 connect(5, {sa_family=AF_INET, sin_port=htons(6100), sin_addr=inet_add +r("XXX.XXX.XXX.XXX")}, 16) = 0 stat("test", {st_mode=S_IFREG|0777, st_size=5, ...}) = 0 stat("test", {st_mode=S_IFREG|0777, st_size=5, ...}) = 0
      What do you think, is it failing to open the file 'test'? and this fails the "command channel"?
        At this point the issue was resolved by using 0.04 Net::FTPSSL