Skip to content

Shellstream is disposed when receiving huge response #1762

Description

@katomark

Hi Guys,

Need your help to resolve my issue.
I send a ssh command to my router "show bgp nei xxx advertised-route", the response is huge and need more than 15 minutes to complete.
If I save the response, the size is 600Mb.

The problem occur when I send the second command, it was said that the shellstream is disposed while my ssh connection is still open.

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Renci.SshNet.ShellStream'.
at Renci.SshNet.ShellStream.Write(String text)
at esihaur.SSH.SSHJob.WriteToStream(String command)

void WriteToStream(string command) { if (isConnected) { ca_Shell.Write(command); ca_Shell.Flush(); } }

public bool isConnected { get { return (ca_client != null && ca_client.IsConnected); } }

Please share guys if any solution

Thank You

Regards,

Activity

  1. Rob-Hague commented on Feb 4, 2026

    @Rob-Hague
    Collaborator

    You can use ShellStream.CanWrite to check if the ShellStream is still open. Not sure why it is closing, maybe the server has a timeout

  2. katomark commented on Feb 4, 2026

    @katomark
    Author

    If I enable paging (-- More --) the connection can stay for hours,, because i need to send " " each time it appear. But I have small issue here.
    So i try to disable the paging, but it's disposed after it receive huge response.

    ShellStream.CanWrite doesn't resolve my issue. It just resolve the exception.
    I tried this

    if (!ShellStream.CanWrite) RecreateStream()

    it start the process from the beginning of ssh session, I need to handle the login again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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