Skip to content

Stream example doesn't seem to work properly #1549

@yuppox

Description

@yuppox

Hi, I am trying to use this stream example:

{
    client.Connect();

    // Make the server echo back the input file with "cat"
    using (SshCommand command = client.CreateCommand("cat"))
    {
        Task executeTask = command.ExecuteAsync(CancellationToken.None);

        using (Stream inputStream = command.CreateInputStream())
        {
            inputStream.Write("Hello World!"u8);
        }

        await executeTask;

        Console.WriteLine(command.ExitStatus); // 0
        Console.WriteLine(command.Result); // "Hello World!"
    }
}

However, I am having issues with it. Frequently, the data doesn't reach the client. So, instead of "Hello World!" the result is empty.

I am trying to use it to write several lines of input via SSH. My client is already connected before I call this.

I tried forcing inputStream.Flush() but it doesn't work reliably and might not make any difference.

How can I fix this? Is there another approach to consider?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions