Code Monkey home page Code Monkey logo

Comments (14)

xucito avatar xucito commented on August 25, 2024

Should the line ClientWindowSize -= packetSize; be present?

from fxssh.

Aimeast avatar Aimeast commented on August 25, 2024

Could please tell me how to re-produce this issue? What's client tool used? Please debug & watch the ClientInitialWindowSize and ClientMaxPacketSize on FxSsh.Services.Channel.cs

from fxssh.

Aimeast avatar Aimeast commented on August 25, 2024

Did you send large data (>ClientInitialWindowSize) at the message loop thread? In another word, did you send this data in service_CommandOpened event?

If yes. Yes , it is TURE make message blocking, going to dead lock.

from fxssh.

Aimeast avatar Aimeast commented on August 25, 2024

Hi, @xucito
Do you have more question?

from fxssh.

xucito avatar xucito commented on August 25, 2024

Hi @Aimeast any data sent via the SendData function will cause this deadlocking. I did send it via the service_CommandOpened event. I have fixed it by removing the ClientWindowSize packetsize subtraction.

xucito@8d3c0b9

from fxssh.

Aimeast avatar Aimeast commented on August 25, 2024

Hi @xucito
Please not do this. This will break flow-control mechanisms and may cause network more jam.
The right way is create new Threading or Task to send BIG message on service_CommandOpened event.

from fxssh.

xucito avatar xucito commented on August 25, 2024

Interesting, should it not close the session then? The behavior where it hangs seems incorrect. Can you link to me where you got the 1MB limitation or the Client Window Size limitation, I am using SSH based tools that hit the limitation quite easily so I am assuming that there is some incorrect behavior in the ssh implementation.

from fxssh.

Aimeast avatar Aimeast commented on August 25, 2024

In design, we can't fix it without redesign. Client Windows Size is send from Client, Server side must observe it.
A way to fix it shall re-design message loop, split message loop to message read thread and handle thread.

from fxssh.

Aimeast avatar Aimeast commented on August 25, 2024

Hi @xucito
Please try https://github.com/Aimeast/FxSsh/tree/fix24

from fxssh.

xucito avatar xucito commented on August 25, 2024

So that seems to work however I am encountering a new issue as a result of the fix you posted:
Seems that when you handle the invoke DataReceived, it is possible for the thread to continue without the full message being acknowledged by the client?

The loop below will sometimes not send the entire message before proceeding to send the closed

foreach (var section in splitResult)
{
          DataReceived?.Invoke(this, Encoding.ASCII.GetBytes(section));
}
CloseReceived?.Invoke(this, 0);
foreach (var section in splitResult)
{
          DataReceived?.Invoke(this, Encoding.ASCII.GetBytes(section));
          Thread.Sleep(500); //This line fixes it
}
CloseReceived?.Invoke(this, 0);

I do not know whether it is a coincidence but I did not have this issue before using my bad fix

from fxssh.

Aimeast avatar Aimeast commented on August 25, 2024

I have tested following code in program.cs service_CommandOpened, no issue found. Could you please tell how do you test and the scene. e.g. the length of section, length of splitResult, condition of network is fast or slow network?

            var rnd = new Random();
            for (int i = 0; i < 10000; i++)
            {
                e.Channel.SendData(Encoding.ASCII.GetBytes(rnd.Next().ToString()));
            }

from fxssh.

xucito avatar xucito commented on August 25, 2024

So this issue is observed when I have some latency (even if its not very much) between the server the client.

When I run both server and client on same machine, I don't encounter the issue, when I have the server and client on their own machines I get the following kinds of errors errors:

OpenSSL 1.0.2k-fips  26 Jan 2017\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 25163\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 10.10.10.16 closed.\r\n

The errors indicate that the client was expecting the rest of the message but received the exit signal.

When I add the sleep, it no longer has this issue.

from fxssh.

Aimeast avatar Aimeast commented on August 25, 2024

I have updated https://github.com/Aimeast/FxSsh/tree/fix24 to test via My phone JuiceSSH client over 20+ times, the test goes to send a big random text. There are no any issues found.

var rnd = new Random();
for (int i = 0; i < 1000; i++)
{
    var str = "";
    for (int j = 0; j < 100; j++) // size tested from 100 to 3000
    {
        str += rnd.Next().ToString();
    }
    e.Channel.SendData(Encoding.ASCII.GetBytes(str));
}

So, can you exactly description how reproduce you issue. Including client name & version, server side simplified code, data size and so on.

from fxssh.

xucito avatar xucito commented on August 25, 2024

Let's close this for now, my client is actually a Ansible OpenSSL client. I will create a different issue when I write a test to reproduce and can reliably replicate this. Thanks for all the help

from fxssh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.