Well, I think I officially failed to get uuleg's example working:
"Failed to open a channel after 10 attempts."
Using:
[2014-06-16 17:46:26,330] SendCommand(sh run object-group id AE) exception caught message:
Failed to open a channel after 10 attempts., Last Milliseconds: 1.0001 [FATAL] Machine: DOOZY User: Pat Process: 64 CallingMethod: SendGetLots LineNumber: 165
[2014-06-16 17:46:27,883] SendCommand(sh run object-group id AE) exception caught toString:
Renci.SshNet.Common.SshException: Failed to open a channel after 10 attempts.
at Renci.SshNet.Channels.ChannelSession.Open()
at Renci.SshNet.SshCommand.BeginExecute(AsyncCallback callback, Object state)
at Renci.SshNet.SshCommand.BeginExecute()
at SendGetLots(String Cmd) in C:...\SecureComms.vb:line 165, Last Milliseconds: 1 [FATAL] Machine: DOOZY User: Pat Process: 64 CallingMethod: SecureComms.SendGetLots LineNumber: 165
[2014-06-16 17:46:29,460] SendCommand(sh run object-group id AE) exception caught stackTrace:
at Renci.SshNet.Channels.ChannelSession.Open()
at Renci.SshNet.SshCommand.BeginExecute(AsyncCallback callback, Object state)
at Renci.SshNet.SshCommand.BeginExecute()
at SecureComms.SendGetLots(String Cmd) in C:...\SecureComms.vb:line 165, Last Milliseconds: 1 [FATAL] Machine: DOOZY User: Pat Process: 64 CallingMethod: SecureComms.SendGetLots LineNumber: 165
I really have no experience with async calls with Renci, so any hints/pointers appreciated. I think maybe there was some other code he used that wasn't included in the snippet that wold have made it work! :)
TIA!
pat
:)
"Failed to open a channel after 10 attempts."
Using:
Public Function SendGetLots(Cmd As String) As String
Dim result As New StringBuilder
'
Try
'
Dim sshCmd As SshCommand = Client.CreateCommand(Cmd)
Dim asynch = sshCmd.BeginExecute() <=== this line (165) fails
Dim reader = New StreamReader(sshCmd.OutputStream)
Do While Not asynch.IsCompleted
' Dim result = reader.ReadToEnd()
result.AppendLine(reader.ReadToEnd())
If String.IsNullOrEmpty(result.ToString) Then
Continue Do
End If
Console.Write(result)
Loop
sshCmd.EndExecute(asynch)
Catch ex As Exception
log.Fatal("SendGetLots(" & Cmd & ") exception caught message: " & vbCrLf & ex.Message())
log.Fatal("SendGetLots(" & Cmd & ") exception caught toString: " & vbCrLf & ex.ToString())
log.Fatal("SendGetLots(" & Cmd & ") exception caught stackTrace: " & vbCrLf & ex.StackTrace())
End Try
Return result.ToString
End Function
yields:[2014-06-16 17:46:26,330] SendCommand(sh run object-group id AE) exception caught message:
Failed to open a channel after 10 attempts., Last Milliseconds: 1.0001 [FATAL] Machine: DOOZY User: Pat Process: 64 CallingMethod: SendGetLots LineNumber: 165
[2014-06-16 17:46:27,883] SendCommand(sh run object-group id AE) exception caught toString:
Renci.SshNet.Common.SshException: Failed to open a channel after 10 attempts.
at Renci.SshNet.Channels.ChannelSession.Open()
at Renci.SshNet.SshCommand.BeginExecute(AsyncCallback callback, Object state)
at Renci.SshNet.SshCommand.BeginExecute()
at SendGetLots(String Cmd) in C:...\SecureComms.vb:line 165, Last Milliseconds: 1 [FATAL] Machine: DOOZY User: Pat Process: 64 CallingMethod: SecureComms.SendGetLots LineNumber: 165
[2014-06-16 17:46:29,460] SendCommand(sh run object-group id AE) exception caught stackTrace:
at Renci.SshNet.Channels.ChannelSession.Open()
at Renci.SshNet.SshCommand.BeginExecute(AsyncCallback callback, Object state)
at Renci.SshNet.SshCommand.BeginExecute()
at SecureComms.SendGetLots(String Cmd) in C:...\SecureComms.vb:line 165, Last Milliseconds: 1 [FATAL] Machine: DOOZY User: Pat Process: 64 CallingMethod: SecureComms.SendGetLots LineNumber: 165
I really have no experience with async calls with Renci, so any hints/pointers appreciated. I think maybe there was some other code he used that wasn't included in the snippet that wold have made it work! :)
TIA!
pat
:)