Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not consume request-specific data for SSH_MSG_GLOBAL_REQUEST #58

Closed
kadje opened this issue Aug 9, 2016 · 7 comments
Closed

Do not consume request-specific data for SSH_MSG_GLOBAL_REQUEST #58

kadje opened this issue Aug 9, 2016 · 7 comments
Assignees
Labels
Milestone

Comments

@kadje
Copy link

kadje commented Aug 9, 2016

Hi guys,

I use latest version of SSH.NET (2016.0.0 beta3). I get the following message and stack flow when my application tries to disconnect from remote server:
System.NotSupportedException: Data longer than 2147483647 is not supported.
at Renci.SshNet.SubsystemSession.WaitOnHandle(WaitHandle waitHandle, TimeSpan operationTimeout)
at Renci.SshNet.Sftp.SftpSession.RequestReadDir(Byte[] handle)
at Renci.SshNet.SftpClient.InternalListDirectory(String path, Action1 listCallback) at Renci.SshNet.SftpClient.ListDirectory(String path, Action1 listCallback)
at DBAService.Logic.FileTransfer.DbaSftpClient.GetCdrAndTrfFiles()
at DBAService.Logic.FileTransfer.FileTransferSession.FileTransferTask() at Renci.SshNet.SubsystemSession.WaitOnHandle(WaitHandle waitHandle, TimeSpan operationTimeout)
at Renci.SshNet.Sftp.SftpSession.RequestReadDir(Byte[] handle)
at Renci.SshNet.SftpClient.InternalListDirectory(String path, Action1 listCallback) at Renci.SshNet.SftpClient.ListDirectory(String path, Action1 listCallback)
at DBAService.Logic.FileTransfer.DbaSftpClient.GetCdrAndTrfFiles()
at DBAService.Logic.FileTransfer.FileTransferSession.FileTransferTask()

Remote server contains txt files which size <5M

Alex.

@drieseng
Copy link
Member

drieseng commented Aug 9, 2016

What SSH server (and version) are you connecting to ?
Would it be possible to temporarily grant me access to that server to allow me to troubleshoot this issue ?

@kadje
Copy link
Author

kadje commented Aug 9, 2016

Unfortunately, I cannot get you access to the server.
Server is 'SSH-2.0-Mocana SSH '

@drieseng
Copy link
Member

drieseng commented Aug 9, 2016

I've contacted them to request to an evaluation version.
What .NET Framework are you targeting ?
Can I somehow send you a custom assembly that includes a little more tracing ?

@kadje
Copy link
Author

kadje commented Aug 9, 2016

.NET Framework 4.0

I can build your debug version on my workstation. Could you provide source code? Also you can send me custom assembly by e-mail

@kadje
Copy link
Author

kadje commented Aug 9, 2016

Note:
Early I used version 2014.4.6 and I got the following messages:

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.Socket'.
at System.Net.Sockets.Socket.get_Available()
at Renci.SshNet.Session.IsSocketConnected(Boolean& isConnected)
at Renci.SshNet.Session.get_IsConnected()
at Renci.SshNet.Session.SendDisconnect(DisconnectReason reasonCode, String message)
at Renci.SshNet.Session.Disconnect(DisconnectReason reason, String message)
at Renci.SshNet.Session.Disconnect()
at Renci.SshNet.BaseClient.Disconnect()
at DBAService.Logic.FileTransfer.DbaSftpClient.CloseConnection() at System.Net.Sockets.Socket.get_Available()
at Renci.SshNet.Session.IsSocketConnected(Boolean& isConnected)
at Renci.SshNet.Session.get_IsConnected()
at Renci.SshNet.Session.SendDisconnect(DisconnectReason reasonCode, String message)
at Renci.SshNet.Session.Disconnect(DisconnectReason reason, String message)
at Renci.SshNet.Session.Disconnect()
at Renci.SshNet.BaseClient.Disconnect()
at DBAService.Logic.FileTransfer.DbaSftpClient.CloseConnection()

or

System.NullReferenceException: Object reference not set to an instance of an object.
at Renci.SshNet.Session.IsSocketConnected(Boolean& isConnected)
at Renci.SshNet.Session.get_IsConnected()
at Renci.SshNet.Session.SendDisconnect(DisconnectReason reasonCode, String message)
at Renci.SshNet.Session.Disconnect(DisconnectReason reason, String message)
at Renci.SshNet.Session.Disconnect()
at Renci.SshNet.BaseClient.Disconnect()
at DBAService.Logic.FileTransfer.DbaSftpClient.CloseConnection() at Renci.SshNet.Session.IsSocketConnected(Boolean& isConnected)
at Renci.SshNet.Session.get_IsConnected()
at Renci.SshNet.Session.SendDisconnect(DisconnectReason reasonCode, String message)
at Renci.SshNet.Session.Disconnect(DisconnectReason reason, String message)
at Renci.SshNet.Session.Disconnect()
at Renci.SshNet.BaseClient.Disconnect()
at DBAService.Logic.FileTransfer.DbaSftpClient.CloseConnection()

Do you have workaround for these exceptions? How I can corectly close connection to server?
Cause of exceptions has been resolved in new version. Is it right?
(END Note)

Do you need more info and what do you think issues #60, #59 and #58 are dependented?

@POC-Tools
Copy link

Hello,
I know this bug was closed, but is it fixed? Because I'm having a similar exception, but on StfClient.Connect().
I'm using Renci.SshNet version 2016.1.0.0 and .net version 4.6.1.

The exception I'm getting is:

System.NotSupportedException: Data longer than 2147483647 is not supported.
   at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout)
   at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle)
   at Renci.SshNet.Session.Connect()
   at Renci.SshNet.BaseClient.Connect()
   at ReportingService.Report.UploadFile(XDocument xdoc, String filename, String username, String host, AuthenticationMethod authenticationMethod) in C:\...\ReportingService\Report.cs:line 232
   at ReportingService.Report.SaveToFtp(XDocument xdoc, String filename) in C:\...\ReportingService\Report.cs:line 202
   at ReportingService.Report.<GenerateReport>d__1.MoveNext() in C:\...\ReportingService\Report.cs:line 112

Here's the code (I'm using PasswordAuthenticationMethod)

        private static void UploadFile(XDocument xdoc, string filename, string username, string host, AuthenticationMethod authenticationMethod)
        {
            var encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true);

            var con = new ConnectionInfo(host, username, authenticationMethod);
            con.Encoding = encoding;
            using (var ftpClient = new SftpClient(con))
            {
                ftpClient.Connect();

                using (var stream = new MemoryStream())
                {
                    using (var writer = XmlWriter.Create(stream, new XmlWriterSettings() { Encoding = encoding }))
                    {
                        xdoc.WriteTo(writer);
                        writer.Flush();
                        stream.Position = 0;
                        ftpClient.UploadFile(stream, filename, canOverride: true);
                    }
                }
                ftpClient.Disconnect();
            }
        }

@dparker61
Copy link

am getting this error
Data longer than 2147483647 is not supported.
during connection to a Tectia ssh server running on a mainframe. The exception gets thrown from this piece of code in IgnoreMessage.cs

'/// </summary>
protected override void LoadData()
{
    var dataLength = ReadUInt32();
    if (dataLength > int.MaxValue)
    {
        throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Data longer than {0} is not supported.", int.MaxValue));
    }'

I downloaded a zip of master, so think I am running the most recent.
My test program is connecting with just username/password.
I would appreciate any clues, or a pointer to the latest branch that has a fix. I'm new to this project and to coding around ssh, so entirely possible this is newbie pilot error.

Any help really appreciated!

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants