Login  
Search All Forums
Dart Home | PowerTCP FTP for .NET | Custom Development Reply | PowerTCP FTP for .NET Topics | Forums   
AuthorForum: PowerTCP FTP for .NET
Topic: The message received was unexpected or badly formatted
mbroniola
mbroniola@compcareservices.com

From: Long Beach, CA USA
Posts: 3
Member Since: 01/24/12
posted January 24, 2012 1:15 PM

Hello,

I'm attempting to connect to sftp.am.gxsics.com however I am receiving this error message:

Message:  The message received was unexpected or badly formatted
Source:  Dart.PowerTCP.Ftp
Stack Trace:  
  at Dart.PowerTCP.Ftp.ai.Invoke(Delegate A_0, Object[] A_1)
  at Dart.PowerTCP.Ftp.Ftp.Invoke(FtpCommand command, String modifier)

They require FTPS and I am passing in the implicit FTP security type.

Here is my code:

Protected WithEvents moFtp As Ftp

Public Sub SetFTPSettings()
    Try
      moFtp = New Ftp()

      If moTradingPartner.FTPTransferType = TransferType.Ascii Then
        moFtp.FileType = FileType.Ascii
      Else
        moFtp.FileType = FileType.Image
      End If

      moFtp.Server = moTradingPartner.Ftphostaddress
      moFtp.Username = moTradingPartner.FtpuserName
      moFtp.Password = moTradingPartner.Ftppassword
      moFtp.Passive = moTradingPartner.FTPPassive
      moFtp.StoreType = StoreType.Replace
      moFtp.ServerPort = moTradingPartner.FTPPort

      If moTradingPartner.FTPSecurityTypeID > 0 Then
        moFtp.UseAuthentication = False ' So It Doesn't Try To Validate SSL Certificate
        moFtp.Security = moTradingPartner.FTPSecurityTypeID
      End If
    Catch oEx As Exception
      Compcare.Log.Logger.LogException(oEx)
    End Try
  End Sub

Private Sub GenericFTPDownloadFiles()
    Try
      Dim oInboxFiles() As FtpFile
      Dim oFile As FtpFile
      Dim sRemoteFiles() As String
      Dim sRemoteFileName As String
      Dim oStream As StreamReader
      Dim sFileText As String
      Dim oDBFile As New File()

      Dim sDownloadDirectory As String

      sDownloadDirectory = moTradingPartner.Ftpdownloaddir

      If sDownloadDirectory Is Nothing Then sDownloadDirectory = "/" Else sDownloadDirectory = sDownloadDirectory.Trim()

      If sDownloadDirectory = "" Then sDownloadDirectory = "/"

      If sDownloadDirectory <> "" AndAlso sDownloadDirectory <> "/" Then
        moFtp.Invoke(FtpCommand.ChangeDir, moTradingPartner.Ftpdownloaddir) <-- Code generates error here
      End If


 I tried changing UseAuthentication = True and SecureProtocol = SecureProtocol.Auto but still received the same error. I also wired up the trace log but my I receive the error before the trace event fires. I confirmed the trace log is working when connecting to other FTP sites.

One other thing I noticed was that when I connect manually using CoreFTP is I have to accept an SSL certificate before connecting. Also, in the CoreFTP log, this is sent before I log in:

Connect socket #1124 to 204.90.130.188, port 6366...
TLSv1, cipher TLSv1/SSLv3 (DHE-RSA-AES256-SHA) - 256 bit

Let me know if you need more information. Thanks for your assistance.
Nick B (Admin)

From: Utica, NY USA
Posts: 572
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted January 24, 2012 2:22 PM

Hello,

Are you able to successfully connect to your server using the included FTP ListView Client sample?

You appear to be using an older version of the component. Does the issue present with the current version? You may download a trial here: http://www.dart.com/ptftpnet.aspx

If your issue continues to present the FTP ListView Client included with version 4.4 of the component, please let me know what server software and version you're connecting to.

------
-Non-current subscribers must contact sales@dart.com to update subscription and receive continued support as needed.
------

mbroniola
mbroniola@compcareservices.com

From: Long Beach, CA USA
Posts: 3
Member Since: 01/24/12
posted January 25, 2012 10:42 AM

Hi Nick,

Sorry for the delayed response. I tried connecting using the ListView app and received this error:

"Received an unexpected EOF or 0 bytes from the transport stream."

 ''' <summary>
  ''' Performs a List on a worker thread and marshals the listing to the UI thread.
  ''' (Executes independent of the UI thread so UI messages are not interrupted).
  ''' </summary>
  Private Sub listWorker(ByVal state As Object)
    'Disable interface
    ftp.Marshal("", False)

    Dim parameters() As Object = CType(state, Object())
    Dim remoteRoot As String = TryCast(parameters(0), String)
    Dim pattern As String = TryCast(parameters(1), String)
    If (Not ftp.Connected) Then
      ftp.Connect() <---Error here
      ftp.Authenticate()
    End If
    ftp.Marshal(ftp.List(remoteRoot, pattern, ListType.Full), remoteRoot, Nothing)

    'Enable interface
    ftp.Marshal("", True)
  End Sub


I asked what the party we are connecting to what server software and version we are connecting to and they only replied with their user user guide for setting up the connection. Could I e-mail you the guide and our login details for you to take a look?
Nick B (Admin)

From: Utica, NY USA
Posts: 572
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted January 25, 2012 2:50 PM

Hello,

Does their user guide specify the FTP server software and version they're using?

Yes, send those into support@dart.com. We'll try to reproduce your issue.

------
-Non-current subscribers must contact sales@dart.com to update subscription and receive continued support as needed.
------

mbroniola
mbroniola@compcareservices.com

From: Long Beach, CA USA
Posts: 3
Member Since: 01/24/12
posted January 26, 2012 11:37 AM

Just checking in...were you able to reproduce the issue?

The party we are connecting to has stated that the server software they are using is confidential.
Nick B (Admin)

From: Utica, NY USA
Posts: 572
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted January 26, 2012 12:49 PM

Hello,

Yes, I replied to your email.
Nick B (Admin)

From: Utica, NY USA
Posts: 572
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted March 5, 2012 11:49 AM

The issue was that SSL 2.0 is disabled by default on most modern operating systems, and the server only supported SSL 2.0

Checking the box for SSL 2.0 in Internet Options will fix this:
http://blogs.msdn.com/b/kaushal/archive/2011/10/02/support-for-ssl-tls-protocols-on-windows.aspx

Or you may set HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Client\DisabledByDefult
to 0.
Reply | PowerTCP FTP for .NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX