0 votes

My hosting service now requires TLS 1.2.

I am trying this library to see if it will work for me but am getting an error:
Tried to read a line. No data received. Please make sure that antivirus and firewall software are disabled or configured correctly.

It logs on fine, but I get the error at the point I try to upload the file.

When I check the server there is a 0-byte file there.

Here is my code:

Try
    fFTPS.Mode = Client.FtpMode.Passive
    fFTPS.SSLConfiguration.EnabledSslProtocols = 
        Security.Authentication.SslProtocols.Tls12
    fFTPS.Connect(Me.FTPHost)
    fFTPS.AuthTLS()
    fFTPS.Login(Me.FTPUsername, Me.FTPPassword)
    If fFTPS.Connected Then
        If LocalUploadFile.Exists Then
            If Not fFTPS.FolderExists(Me.FTPFolder) Then
                fFTPS.CreateFolder(Me.FTPFolder)
            End If
            fFTPS.ChangeFolder(Me.FTPFolder)

            Dim ulBytes As Byte() = Encoding.Default.GetBytes(
                LocalUploadFile.FullName)

            Response = fFTPS.Upload(RemoteUploadFile, ulBytes)
                .Message

            If fFTPS.FileExists(RemoteUploadFile) Then
                Me.LastFTPError = "ok"
                Return True
            Else
                Me.LastFTPError = "upload file not found"
                Return False
            End If
        Else
            Me.LastFTPError = "local file missing"
            Return False
        End If
    Else
        Me.LastFTPError = "FTP Did not connect!"
        Return False
    End If
Catch ex As Exception
    Me.LastFTPError = ex.Message
    Return False
Finally
    Try
        If fFTPS.FileExists(RemoteUploadFile) Then
            fFTPS.DeleteFile(RemoteUploadFile)
        End If
    Catch ex As Exception
        'don't care
    End Try

    fFTPS.Close()

    If LocalUploadFile.Exists Then
        LocalUploadFile.Delete()
    End If

End Try

Got it:
Here is the output:

2.0.20006.1858
Connecting to 'www.redactive.com:21', SSL: False.
Control connection uses port: 51264 (200,64)
S: 220-------- Welcome to Pure-FTPd [privsep] [TLS] --------
S: 220-You are user number 2 of 50 allowed.
S: 220-Local time is now 13:10. Server port: 21.
S: 220-This is a private system - No anonymous login
S: 220-IPv6 connections are also welcome on this server.
S: 220 You will be disconnected after 15 minutes of inactivity.
C: AUTH TLS
S: 234 AUTH TLS OK.
C: USER
S: 331 User OK. Password required
C: PASS
S: 230 OK. Current restricted directory is /
C: FEAT
S: 211-Extensions supported:
S: EPRT
S: IDLE
S: MDTM
S: SIZE
S: MFMT
S: REST STREAM
S: MLST type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;
S: MLSD
S: AUTH TLS
S: PBSZ
S: PROT
S: UTF8
S: TVFS
S: ESTA
S: PASV
S: EPSV
S: SPSV
S: ESTP
S: 211 End.
C: OPTS UTF8 ON
S: 200 OK, UTF-8 enabled
C: PWD
S: 257 "/" is your current location
C: MLST severestudios
S: 250-Begin
S: type=dir;sizd=4096;modify=20200506170836;UNIX.mode=0755;
   UNIX.uid=995;UNIX.gid=944;unique=fd00g1f1c05d; severestudios
S: 250 End.
C: CWD severestudios
S: 250 OK. Current directory is /severestudios
C: TYPE I
S: 200 TYPE is now 8-bit binary
C: PBSZ 0
S: 200 PBSZ=0
C: PROT P
S: 200 Data protection level set to "private"
C: PASV
S: 227 Entering Passive Mode (216,222,194,88,172,123)
C: STOR tmp237F.tmp
S: 150 Accepted data connection
Data connection established.
Exception thrown: 'Limilabs.FTP.Client.FtpException' in Ftp.dll

The exception message is: Tried to read a line. No data received. Please make sure that antivirus and firewall software are disabled or configured correctly.

Note: WinSCP works so the issue is not with my firewall.

by
Your problem is most likely not with TLS 1.2 - as you said - it connects and logs-in just fine.

What FTP server are you using?

At what line are you getting this error?

Please turn on logging:
https://www.limilabs.com/blog/logging-in-ftp-dll

P.S.
There's no point in checking Connected property in your code.
Thanks - checking connected is more of a habit I guess.
I tried turning logging on with

Limilabs.FTP.Log.Enabled = True

Just above the Try block, but nothing appears in the debug output window when I run the code.
Please read the article carefully, it shows different way of obtaining the logs:
https://www.limilabs.com/blog/logging-in-ftp-dll

If you are unable to make it work, subscribe to Limilabs.FTP.Log.WriteLine event.

1 Answer

0 votes

My assumption is session resumption issue described here:
https://www.limilabs.com/blog/ftp-tls-encrypted-data-connections-fail-ems

In short:
Windows started enforcing more secure version of session resumption called EMS.

EMS is not supported by older servers (those using OpenSSL libraries older than version 1.1.0)

Upgrading Pure-ftpd to version >1.0.46 should resolve this issue.


This logs shows that control connection was established without any problems.

It also shows that the 2nd data connection was established ("Data connection established."), transfer performed.

Client than waits for the server response on the control connection, which is not received -> "Tried to read a line. No data received. "

Are you sure you are actually transferring any data?
Is ulBytes non empty?
Is Ftp.OnProgress event fired, how many times?

WinSCP in not FTPS client.

by (301k points)
edited by
Hi:
Thanks.  Yes there is indeed data.  OnProgress is fired twice initially showing 0 of 54 bytes to be transferred. The second time it is triggers it shows that 54 bytes were transferred.  On the server a 0 byte file exists after the exception and the connection is closed.  The file is not originally a 0 byte file.
This is very strange as it shows that the data was actually transferred to the server.

To be honest this looks like a server error/bug.

Can you try uploading larger/actual file?

Would it be possible to create a test account for us?
HI:
I agree that there could be a server configuration error - both WinSCP and Filezilla will transfer files without error.  I've contacted my hosting provider and they say that since WinSCP and FileZilla work that I need to work with my FTP Library vendor. So here I am - stuck in the middle...
Yes - happy to provide you with a test account on my server:
Is there an email address I can send the credentials to instead of posing them on this public forum?
Please use the support email address. Thanks!
...