Skip to content

Fail after trying to find the optimal transfer mode #213

@gilles-crealp

Description

@gilles-crealp

Describe the bug
Reading the content of an FTP was working in version 4 but not anymore in version 5.

Example code

import * as ftp from 'basic-ftp'

async function example () {
  const client = new ftp.Client()
  client.ftp.verbose = true
  try {
    await client.access({
      host: '***,
      user: '***',
      password: '***'
    })
    console.log(await client.pwd())
    console.log(await client.list())
  } catch (err) {
    console.log(err)
  }
  client.close()
}

example()

Console output version 5.0.0

Connected to ***:21 (No encryption)
< 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number *** of *** allowed.
220-Local time is now **:**. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.

Login security: No encryption
> USER ***
< 331 User *** OK. Password required

> PASS ***
< 230 OK. Current directory is /

> FEAT
< 211-Extensions supported:
 UTF8
 EPRT
 IDLE
 MDTM
 SIZE
 MFMT
 REST STREAM
 MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
 MLSD
 PRET
 AUTH TLS
 PBSZ
 PROT
 TVFS
 ESTA
 PASV
 EPSV
 ESTP
211 End.

> TYPE I
< 200 TYPE is now 8-bit binary

> STRU F
< 200 F OK

> OPTS UTF8 ON
< 504 Unknown command

> OPTS MLST type;size;modify;unique;unix.mode;unix.owner;unix.group;unix.ownername;unix.groupname;
< 200  MLST OPTS type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;

> PWD
< 257 "/" is your current location

/
> FEAT
< 211-Extensions supported:
 UTF8
 EPRT
 IDLE
 MDTM
 SIZE
 MFMT
 REST STREAM
 MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
 MLSD
 PRET
 AUTH TLS
 PBSZ
 PROT
 TVFS
 ESTA
 PASV
 EPSV
 ESTP
211 End.

> EPSV
< 500 Unknown command

FTPError: 500 Unknown command
    at FTPContext._onControlSocketData (***\node_modules\basic-ftp\dist\FtpContext.js:283:39)
    at Socket.<anonymous> (***\node_modules\basic-ftp\dist\FtpContext.js:124:44)
    at Socket.emit (node:events:526:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:285:11)
    at Socket.Readable.push (node:internal/streams/readable:228:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  code: 500
}
> QUIT

Console output version 4.6.6

Connected to ***.***.***.***:21 (No encryption)
< 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number *** of *** allowed.
220-Local time is now **:**. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.

Login security: No encryption
> USER ***
< 331 User *** OK. Password required

> PASS ***
< 230 OK. Current directory is /

> FEAT
< 211-Extensions supported:
 UTF8
 EPRT
 IDLE
 MDTM
 SIZE
 MFMT
 REST STREAM
 MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
 MLSD
 PRET
 AUTH TLS
 PBSZ
 PROT
 TVFS
 ESTA
 PASV
 EPSV
 ESTP
211 End.

> TYPE I
< 200 TYPE is now 8-bit binary

> STRU F
< 200 F OK

> OPTS UTF8 ON
< 504 Unknown command

> OPTS MLST type;size;modify;unique;unix.mode;unix.owner;unix.group;unix.ownername;unix.groupname;
< 200  MLST OPTS type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;

> PWD
< 257 "/" is your current location

/
Trying to find optimal transfer mode...
> EPSV
< 500 Unknown command

Transfer mode failed: "500 Unknown command", will try next.
> PASV
< 227 Entering Passive Mode (217,26,55,204,177,182)

Optimal transfer mode found.
> MLSD
< 150 Accepted data connection
226 4 matches total

Downloading from ***:*** (No encryption)
type=cdir;sizd=***;modify=***;UNIX.mode=02755;UNIX.uid=***;UNIX.gid=***;unique=***; .
type=pdir;sizd=***;modify=***;UNIX.mode=02755;UNIX.uid=***;UNIX.gid=***;unique=***; ..
type=dir;sizd=***;modify=***;UNIX.mode=02755;UNIX.uid=***;UNIX.gid=***;unique=***; ***
type=dir;sizd=***;modify=***;UNIX.mode=02755;UNIX.uid=***;UNIX.gid=***;unique=***; ***

[
  FileInfo {
    ***
  },
  FileInfo {
    ***
  }
]

Which version of Node.js are you using?
Node 16.14.2

Additional context
I do not manage the FTP.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions