Connected event never gets fired (wodSFTP / wodSFTP.NET / wodSFTPdll)
Hello, I was using wodSFTP component for several years and it worked fine. Now we switched to Windows 16 server and I've rewritten the VB6 code in VB17. Everything seems to be in order, but Connected event never gets fired after Connect method is used. I'm not getting any errors, it's just stuck and doing nothing. Are there any tricks related to Win 16 or VB17? Could you please take a look at my code below and tell me what's wrong with it?
Dim fsoObj As Object, objFolder As Object, objFile As Object, objStream As Object
Dim connMy As ADODB.Connection, rsMy As ADODB.Recordset, connAS400 As ADODB.Connection, rs400 As ADODB.Recordset
Dim strSQL As String
Dim sftpMy As New wodSFTPCOMLib.wodSFTPCom
Private Sub frmMy_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With sftpMy
.LicenseKey = "xxx"
.Hostname = "SFTP.xxx.yyy.COM"
.Authentication = wodSFTPCOMLib.AuthenticationsEnum.authPassword
.Login = "zzzzzzzzz"
.Password = "pppppp"
.Port = 22
.Resume = True
.Blocking = True
.Connect()
End With
NowState = States.Connecting
AddList("CONNECTING")
End Sub
Private Sub sftpMy_Connected(ByVal ErrorCode As Integer, ByVal ErrorText As String)
If ErrorCode <> 0 Then
AddList("Connect Failed " & ErrorText)
Exit Sub
End If
AddList("CONNECTED")
sftpMy.ListNames(<REMOTE_FOLDER>)
NowState = States.Downloading
End Sub
Connected event never gets fired
Hi Kiril,
it is dangerous to use events together with blocking mode - especially to execute blocking methods within events which are fired by other blocking command. Connect method blocks, fires event, you call ListNames who blocks again - as a result everything could block.
You don't need events when blocking is used, since you can move code from without Connected event just to line after Connect method - since that line will block until it completes.
Does your code after Connect method call ever is reached? If so, component did connect. Can you check?
Jasmine.
Connected event never gets fired
Hi Jasmine,
Thanks for your quick response, I appreciate your help greatly!
As you suggested, I've tried commenting out Connected event and using ListNames method right after Connect method. The result is the same - ListItems event never fires and nothing's happening. It doesn't look like the component is connected to SFTP server.
Actually, I've only tried adding Blocking mode after a long struggle to make Connected event fire. It seems like after using Connect method, the component just idle without connecting and without giving any errors either.
Thanks for your help,
Kiril
Connected event never gets fired
Hi Kiril,
can you create new empty project same as yours, just put relevant lines of code to it, make sure it behaves the same as for you, and send it over (techsupport - at - weonlydo.com). We will debug it to see what's going on and why events do not fire.
I assume this is desktop project made in VB.NET?
Jasmine
Connected event never gets fired
Hi Kiril,
I'm no VB.NET expert, but how does VB know that
Private Sub sftpMy_Connected(ByVal ErrorCode As Integer, ByVal ErrorText As String)
is wodSFTP's event? Shouldn't there be 'Handles' or something like that?
Jasmine.
Connected event never gets fired
Jasmine,
My project is actually MS Visual Studio project written in Visual Basic 2017. I've created a new project with only wodSFTP-related code and will e-mail it to you right away.
Thanks a lot for your help and speedy response,
Kiril
Connected event never gets fired
Hi Jasmine,
My project uses VB 2017, it doesn't require handles.
Thanks,
Kiril
Connected event never gets fired
Hi Kiril,
ok, I'm no VB.NET expert, but in your code I added 'Withevents' keyword like in VB6,
Dim WithEvents sftpMy As New wodSFTPCOMLib.wodSFTPCom
and then sftpMy appeared in object browser, and I could choose event on rightmost dropbox, and code for it was autocreated, and it does contain Handles
Private Sub sftpMy_Connected(ErrorCode As Short, ErrorText As String) Handles sftpMy.Connected
and it does get fired. You can copy/paste code to it from your event that wasn't recognized as wodSFTP's event.
Can you try that?
Jasmine.
Connected event never gets fired
Jasmine, you were right, I have not declared the component object WithEvents. That's why the events were never called. If works fine now.
Thank a lot,
Kiril
Connected event never gets fired
The problem solved, thank you very much for your excellent support!