SSH connection issue - WeOnlyDo Discussion board

SSH connection issue (wodSSH / wodSSH.NET)

by enaiman, Thursday, October 18, 2007, 02:45 (6045 days ago)

When I try to use SSH to connect to a switch which doesn't support SSH my application close with a message

The requested action with this object has failed.:
$Telnet1.Connect

here is a part of my code:
- creating the object and setting some general properties
[code]$Telnet1 = ObjCreate( WeOnlyDo.wodTelnetDLX.1 )
ObjEvent($Telnet1, Telnet1_ )
$Telnet1.Prompt = #
$Telnet1.BackColor = 0x000000
$Telnet1.ForeColor = 0x00FF00
$Telnet1.Rows = 30
$Telnet1.BackLog = 60
$Telnet1.Columns = 200[/code]

- create the GUI
[code]$Telnet1_ctrl = GUICtrlCreateObj($Telnet1, 11, 72, 505, 313)
$Telnet1.HostName = 192.168.0.20 [/code]

- here I start the SSH mode
[code]$Telnet1.Protocol = 4
$Telnet1.Authentication =1
$Telnet1.Login = username
$Telnet1.Password = password
$Telnet1.Enabled = True
$Telnet1.Connect
Sleep(1000)
If $errc <> 0 Then
stat_setdata( Connection Error: &$errc, 0)
Return
Else
stat_setdata( Connected to 192.168.0.20 using SSH , 0)
EndIf[/code]

$errc is the error code returned by this event function:
[code]Func Telnet1_Connected($ErrorCode, $ErrorText)
$errt = $ErrorText
$errc = $ErrorCode
EndFunc[/code]
The point is - the Connect event is not fired and I don't have any idea about what happens ... sure thing my application exits. I would like to get something like an error or an event to be fired (which one?) in this case (remote host not supporting SSH) - so I can detect it and take some action.
I would be grateful if someone could tell me what to do in this case.
Thank you,

Re: SSH connection issue

by wodSupport, Thursday, October 18, 2007, 02:53 (6045 days ago) @ enaiman

Enaiman,

I can try to help, even I'm not sure what programming language you're using.

When your app closes, wodTelnetLDX dies too. It cannot survive it. However, it lives in same thread as your app, so Sleep API call doesn't help - because you put same thread to sleep where wodTelnetDLX lives.. Can you change that Sleep API more to look like the message pump (GetMessage...TranslateMessage..DispatchMessage..)?

Is your app window based? Or console based? Does it have its own window? Do you need GUI at all? If you don't need GUI, you could use wodTelnetDLXCom instead, and then simply set Blocking property to True in which case you wouldn't even need Sleep/pump.

Kreso

Re: SSH connection issue

by enaiman, Thursday, October 18, 2007, 03:09 (6045 days ago) @ wodSupport

Enaiman,
I can try to help, even I'm not sure what programming language you're using.

@Kreso Thank you for your reply,

I'm using AutoIt, which is a Windows application.
I'm creating a GUI and the Telnet object is embedded in it ( my application is used to configure network switches over serial connection or Telnet/SSH)

EDIT: I've found a way to convince my AutoIt to not exit on such events and everything looks better now :)
Thanks,