MBS Network - SSH Read issue.

Hi all

I’m facing at an issue with SSH.
When i’m connecting through ssh, i try to send a cmd line and sometimes i’ve a result and sometimes none.
I use an example provided with the plugin.

dim s as string = channel.Read(10000)
Self.Console.Text = Self.Console.Text + s

app.DoEvents 10
call channel.Write “ls -al” + EndOfLine.UNIX

app.DoEvents 10
s = channel.Read(10000)
if channel.LastError = session.kErrorEagain then
// no answer yet
Self.Console.Text = Self.Console.Text + s
end if

It looks like that the code stays in // no answer yet.

Any idea?

do you check lasterror after write?
Maybe the write is not successful.

Hello Christian.

lasterror returns -37

It seems to be this.

[quote]7.17.54 kErrorEagain = -37
Plugin Version: 14.0. Function: One of the SSH error codes.
Notes: Please try again later.[/quote]

Hmmm, i don’t know what it means. :frowning:

please make a loop.

dim command as string = "ls -al" + EndOfLine.UNIX do call channel.Write command loop until channel.lasterror <> -37

So you can try several times.

Hmm no result.
If i send a Write and a Read immediatly after sending a Write, there’s no content in this result.
Sometimes yes, but it’s rare.

Maybe you should do the Read before in a loop till it’s done.

The error is telling you that it is not in the state where you write. Maybe you need to read more first.

Ok, i’ll try to make some test later with your comments.

In any cases, my project is only for sending several cmd lines and close the SSH connection after.
Not really need to see what’s happened.
The most important is , the cmd lines are sent and valid by the device.
My app is made for use a template for any switch and send them through SSH consle from a template.
This template will be modified by some fields in the desktop app and sent to the switch.
Next the connection will be closed after this sending.

I’ve made some tests and it works fine.
Excepted that i would like to have any traces of this sending.
But that should be for another time.

Thanks any cases for your help Christian.
If i’ve some problems about that, i’ll let you know :slight_smile:

Ha… Welcome so :smiley:

I also have this problem where no matter what I do I can’t get everything from the buffer. I always just wondered if this was an SSHLib2 bug. This has always plagued me since I paid Christian to wrap this C project a few years back. (https://www.libssh2.org/)

Christian what version of LibSSH2 do you have wrapped? The latest is 1.7 from Feb 2016.


Looking on my site I use 1.7.

And we sit together at XDC and work on this.

I wish I could come to XDC, but fortunately we have a lot of business to attend to here. I will provide any info I can to help this as unfortunaetly I abandoned using the SSH class from your Network Plugin over a year ago. I just ran out of time to deal with it, but I have more time now to help see if though since others are also experiencing this issue now.