EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Wrong socket state 4 in Init (error code is 96258)

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
Posted: 11/03/2008 14:02:43
by skylar hayes (Standard support level)
Joined: 11/03/2008
Posts: 7

I looked at the simple SFTPDemo recently and wanted to create my own function that can connect to a SFTP site. I basically am trying to make the simplest function possible that will connect correctly. I kept all of the sftpclient settings from the demo minus my own username/password/address/port. I have a simple connect function that attempts to connect to the sftp server. When i get to the line of code sftpclient.open i throw the error:
Wrong socket state 4 in Init (error code is 96258)

In the demo the same connection information works perfectly. Now in my own code I get the (96258) error.

Could you help me troubleshoot this error?

Me.SftpClient.ASCIIMode = False
Me.SftpClient.AuthAttempts = 1
Me.SftpClient.AuthenticationTypes = 20
Me.SftpClient.AutoAdjustCiphers = False
Me.SftpClient.AutoAdjustTransferBlock = True
Me.SftpClient.CertAuthMode = SBSSHClient.TSBSSHCertAuthMode.camAuto
Me.SftpClient.ClientHostname = ""
Me.SftpClient.ClientUsername = ""
Me.SftpClient.CompressionLevel = 6
Me.SftpClient.DefaultWindowSize = 2048000
Me.SftpClient.DownloadBlockSize = 8192
Me.SftpClient.ForceCompression = False
Me.SftpClient.IncomingSpeedLimit = 0
Me.SftpClient.KeepAlivePeriod = CType(0, Long)
Me.SftpClient.KeyStorage = Nothing
Me.SftpClient.LocalAddress = Nothing
Me.SftpClient.LocalNewLineConvention = New Byte() {CType(13, Byte), CType(10, Byte)}
Me.SftpClient.LocalPort = 0
Me.SftpClient.MinWindowSize = 2048
Me.SftpClient.NewLineConvention = New Byte() {CType(13, Byte), CType(10, Byte)}
Me.SftpClient.OperationErrorHandling = SBSftpCommon.TSBOperationErrorHandling.oehTryAllItems
Me.SftpClient.OutgoingSpeedLimit = 0

Me.SftpClient.PipelineLength = 32

Me.SftpClient.RequestPasswordChange = False
Me.SftpClient.SftpBufferSize = 131072
Me.SftpClient.SFTPExt = Nothing
Me.SftpClient.SocketTimeout = 0
Me.SftpClient.SocksAuthentication = 0
Me.SftpClient.SocksPassword = ""
Me.SftpClient.SocksPort = 1080
Me.SftpClient.SocksResolveAddress = False
Me.SftpClient.SocksServer = Nothing
Me.SftpClient.SocksUserCode = ""
Me.SftpClient.SocksVersion = 1
Me.SftpClient.SoftwareName = "EldoS.SFTPBlackbox.5"
Me.SftpClient.SSHAuthOrder = SBSSHCommon.TSBSSHAuthOrder.aoDefault
Me.SftpClient.Tag = Nothing
Me.SftpClient.ThreadSafe = True
Me.SftpClient.TrustedKeys = Nothing
Me.SftpClient.UploadBlockSize = 32768
Me.SftpClient.UseInternalSocket = True
Me.SftpClient.Username = ""
Me.SftpClient.UseSocks = False
Me.SftpClient.UseUTF8 = True
Me.SftpClient.UseWebTunneling = False
Me.SftpClient.Versions = CType(28, Short)
Me.SftpClient.WebTunnelAddress = Nothing
Me.SftpClient.WebTunnelAuthentication = 0
Me.SftpClient.WebTunnelPassword = Nothing
Me.SftpClient.WebTunnelPort = 3128
Me.SftpClient.WebTunnelUserId = Nothing

Sub ConnectSFTP()

If SftpClient.Active Then
System.Windows.Forms.MessageBox.Show(Me, "Already connected")
Exit Sub
End If

SftpClient.Username = "holt"
SftpClient.Password = "*censored*"
SftpClient.Address = "sftp.banko.com"
SftpClient.Port = 22


SftpClient.AuthenticationTypes = SftpClient.AuthenticationTypes And Not SBSSHConstants.Unit.SSH_AUTH_TYPE_PUBLICKEY

Catch ex As Exception
Log("Connection failed due to exception: " + ex.Message, True)
Log("If you have ensured that all connection parameters are correct and you still can't connect,", True)
Log("please contact EldoS support as described on http://www.eldos.com/sbbdev/support.php", True)
Log("Remember to provide details about the error that happened.", True)
If SftpClient.ServerSoftwareName.Length > 0 Then
Log("Server software identified itself as: " + SftpClient.ServerSoftwareName, True)
End If
End Try
Exit Sub
End Try
Log("SFTP connection established", False)
currentDir = "."

End Sub
Posted: 11/03/2008 14:54:07
by Eugene Mayevski (EldoS Corp.)

1) Don't crosspost your questions to forum and helpdesk. Helpdesk ticket has been deleted as redundant.

2) Your code is missing at least one thing: event handler for OnKeyValidate event.

3) Your code doesn't handle OnSSHError and this event would give you additional information about SSH error if one happens.

Please correct items 2 and 3 and see the results.

Sincerely yours
Eugene Mayevski
Posted: 11/03/2008 17:00:58
by skylar hayes (Standard support level)
Joined: 11/03/2008
Posts: 7

2.) I didn't copy all of my code, the onkeyvalidate event is handled as follows:

Private Sub SftpClient_OnKeyValidate(ByVal Sender As Object, ByVal ServerKey As SBSSHKeyStorage.TElSSHKey, ByRef Validate As Boolean) Handles SftpClient.OnKeyValidate
Log("Server key received, fingerprint is " + SBUtils.Unit.DigestToStr128(ServerKey.FingerprintMD5, True), False)
Validate = True
End Sub

I don't handle the OnSSHError because the simpleSFTPDemo ALSO does not handle this event. Where should the onssherror be handled... sftclient does not have that event so what class does?

Again, this is just a simpler version of the simpleSFTPDemo i am only taking code out, i didn't want to add any extra code unless it was to help debug my application.
Posted: 11/04/2008 00:43:48
by Ken Ivanov (EldoS Corp.)

The correct name of the event is OnError (not OnSSHError).

Please check if OnError and OnKeyValidate events do fire. If they don't, please use the following guidelines to troubleshoot the issue.
Posted: 11/05/2008 10:31:33
by skylar hayes (Standard support level)
Joined: 11/03/2008
Posts: 7

OnError event has been handled. It is NOT being fired:
Private Sub SftpClient_OnError(ByVal Sender As Object, ByVal ErrorCode As Integer) Handles SftpClient.OnError
Log("SFTP error " + ErrorCode.ToString(), True)
End Sub

I have tried the following:
1. Turn off compression.
2. I have no firewall and am behind no proxy
3. I turned off all algorithms:

For i As Integer = SSH_EA_FIRST To SSH_EA_LAST
SftpClient.EncryptionAlgorithms(i) = False
SftpClient.EncryptionAlgorithms(SSH_EA_3DES) = True

For i As Integer = SSH_PK_FIRST To SSH_PK_LAST
SftpClient.PublicKeyAlgorithms(i) = False
SftpClient.PublicKeyAlgorithms(SSH_PK_RSA) = True

For i As Integer = SSH_MA_FIRST To SSH_MA_LAST
SftpClient.MacAlgorithms(i) = False
SftpClient.MacAlgorithms(SSH_MA_HMAC_MD5) = True

7. I don't understand this reccomendation:
It can happen that your user account doesn't allow you to access the server using the chosen subsystem (shell, command, sftp). In this case the connection step is almost completed and then you get (or don't get) the error message and the connection is closed. In this case you can try other subsystem and then you need to contact your server administrator.

Again, the sample code works fine...I have compared all client properties and they are the same between my code and the sample's code.

Any suggestions as to why i keep getting the same
Wrong socket state 4 in Init (error code is 96258) and no events are firing?
Posted: 11/05/2008 15:24:24
by skylar hayes (Standard support level)
Joined: 11/03/2008
Posts: 7

Also i get a long wait on the client.open command. If i put a breakpoint here, it will take a long time before it allows me to even step through that point. Any suggestions?
Posted: 11/05/2008 17:03:05
by skylar hayes (Standard support level)
Joined: 11/03/2008
Posts: 7

None of the handled events from the Simplesftp Demo are being fired in my project. The 96258 error is thrown in the "catch statement" occurs directly after the sftpclient.open() line. I have tried each authenticationType, all of them still give the same error.
I have followed all the guidelines(http://www.eldos.com/sbbdev/articles/4796.php) still to no avail.

This is a timely issue, My business wants to buy a 3rd party sftp module that integrates with .net. I am currently using the trial version but if it does not work i can not ask my company to buy this blackbox software.
Posted: 11/06/2008 00:27:43
by Ken Ivanov (EldoS Corp.)

Try to set AutoAdjustCiphers property to true and check if it changes something.
Posted: 11/06/2008 12:56:59
by skylar hayes (Standard support level)
Joined: 11/03/2008
Posts: 7

I tried setting the autoadjustproperty still to no avail. I will attach my file and tell me if i am looking over something?

[ Download ]
Posted: 11/07/2008 00:02:36
by Ken Ivanov (EldoS Corp.)

Your code works fine for us. Can it be so that firewall blocks your application?
Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.



Topic viewed 10460 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!