Archived Forum Post

Index of archived forum posts

Question:

ftp directory listing fails when no files match pattern

Apr 25 '13 at 08:44

If I specify a ListPattern (e.g., ".txt"), NumFilesAndDirs returns -1 if no files match the pattern. If I keep all the same settings but a file matches the pattern, it succeeds. If I set ListPattern to "" it succeeds.

Here is the LastErrorText:

ChilkatLog:
  NumFilesAndDirs:
    DllDate: Apr 11 2013
    ChilkatVersion: 9.4.1.0
    UnlockPrefix: ****
    Username: ****
    Architecture: Little Endian; 32-bit
    Language: .NET 4.0
    VerboseLogging: 0
    FTP directory cache not fresh.  Fetching dir listing...
    checkDirCache_listPattern:
      supportsMLSD: 0
      MLSD is only used for full directory listings.  Using LIST instead...
      ListDir:
        Sent PROT P command.
        ProtPResponse: 200 PROT command successful.
        Passive transfer mode
        setupPassiveDataSocket1:
          hostAddr: ****
          DataConnect:
            hostname: ****
            port: 52574
            ConnectTimeoutMs_1: 30000
            calling ConnectSocket2
            IPV6 enabled connect with NO heartbeat.
            This is an IPV4 numeric address...
            AddrInfoList:
              AddrInfo:
                ai_flags: 4
                ai_family: 2
                ai_socktype: 1
                ai_protocol: 0
                ai_addrlen: 16
                ai_canonname: (NULL)
              --AddrInfo
            --AddrInfoList
            Connect using IPV4.
            ipAddress1: ****
            myIP_3: ****
            myPort_3: 50873
            connect successful (2)
            socketOptions:
              SO_SNDBUF: 8192
              SO_RCVBUF: 8192
              TCP_NODELAY: 8192
            --socketOptions
          --DataConnect
        --setupPassiveDataSocket1
        SendingFtpCommand:
          sendingCommand: LIST *.dat
        --SendingFtpCommand
        Failed to convert listDir data socket to TLS
        listDir_fail_11
      --ListDir
    --checkDirCache_listPattern
    N: -1
    Failed.
  --NumFilesAndDirs
--ChilkatLog

Answer

In the FTP protocol, directory listings are transferred on a separate data channel just like file download and uploads. It must be that for this FTP server, when no files match the pattern, that it entirely skips the establishment of the data channel (which is why you see the error listed as "Failed to convert listDir data socket to TLS")

I'll investigate. If I cannot reproduce the problem, it's likely because the FTP servers I have for testing don't behave in this way. In that case, I'll try to make a change that should work, and then you can test it. (The new build may take a day or so because of other work in progress..)

I'll post here when the new build is ready.