Ftp A Call To SPPI Failed - The buffers supplied to a function was too small

0 votes

Hi

I'm connecting to an FTP server which works 90% of the time but every now and again i'm receiving the following error.

[ERROR] 2017-01-18 15:00:13,674 – An error occured during the Connect event with an Exception message A call to SSPI failed, see inner exception. and stacktrace at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
inner exception System.ComponentModel.Win32Exception (0x80004005): The buffers supplied to a function was too small

this error occurs on the client.AuthTLS() line any help would be appreciated

public Ftp Connect(Entities.FtpAccount ftpAccount, FtpProtocol ftpProtocol)
{
    Ftp client = new Ftp();

    try
    {
        client.Connect(ftpAccount.Url);
        client.Mode = FtpMode.Passive;

        switch (ftpProtocol)
        {
            case FtpProtocol.Ftp:
                 break;
            case FtpProtocol.Ftps:
                 client.ServerCertificateValidate += ValidateCertificate;
                 client.AuthTLS();
                 break;
            default:
                 break;
        }

        client.Login(ftpAccount.Username, ftpAccount.Password);

        return client;
    }
    catch (FtpException ftpe)
    {
            log.ErrorFormat($"An error occured during the Connect event");
            return client = null;
            throw;
    }
    catch (Exception e)
    {
        log.ErrorFormat($"An error occured during the Connect event");
        return client = null;
        throw;
        }
    }
asked Jan 18, 2017 by Darren (720 points)

1 Answer

0 votes

First of all make sure you dispose Ftp instance, both on error and during regular flow.

As for the error:
no buffers are supplied by Ftp.dll to SslStream.AuthenticateAsClient(), so the problem might be in the System.Net, it is possible to find similar reports (https://github.com/dotnet/corefx/issues/1854) and the consensus is this is a .NET problem.

Are you using Windows 8.1?

The only workaround I can think of is to dispose Ftp instance and try again. I'm not sure, if we can do anything on the Ftp.dll side.

answered Jan 18, 2017 by Limilabs support (230,760 points)
Thanks will ensure that the instance is correctly disposed of.

I did read the same github article you'v posted one of the proposed solutions was to just retry the connection when it failed as it would work the second time...

I'm using Windows 10 on my development PC and then deployed to a server with Windows Server 2008 R2 Standard.

I will try dispose the Ftp Instance and then in the catch and try the connect code again.
...