8000
  • lock SendData to fix random connection failures by mus65 · Pull Request #1623 · sshnet/SSH.NET · GitHub
    [go: up one dir, main page]

    Skip to content

    lock SendData to fix random connection failures#1623

    Merged
    Rob-Hague merged 1 commit intosshnet:developfrom
    mus65:fix1253
    Mar 29, 2025
    Merged

    lock SendData to fix random connection failures#1623
    Rob-Hague merged 1 commit intosshnet:developfrom
    mus65:fix1253

    Conversation

    @mus65
    Copy link
    Contributor
    @mus65 mus65 commented Mar 29, 2025

    Fixes #1253 and probably #1493 .

    This adds a lock to SendData to avoid the loop to interleave between multiple messages, causing a "bad message" error in the server (see #1253 (comment)).

    This may totally be the wrong fix since I'm not really familiar with the protocol and I couldn't find anything specifically about this in the RFCs. But it seems sensible to me that the server doesn't expect this to happen.

    By adding some logging I confirmed that in the failure cases of the test, the loop did indeed interleave between different messages. In the success cases, there simply were never more than 1 iteration, so it couldn't interleave.

    Without this fix, I had the test fail about every third run. With this fix, I have run the test for about 500 times without a failure.

    @Rob-Hague
    Copy link
    Collaborator

    Nice! It makes sense: the SFTP layer has its own length-prefixed packets so when they are being (wrongly) split up in the channel layer, the server reads an SFTP packet, tries to read the length of the next SFTP packet but ends up reading some random bytes in the middle of a different packet. Good find

    @Rob-Hague Rob-Hague merged commit c318e39 into sshnet:develop Mar 29, 2025
    4 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    Unstable integration test Test_Sftp_Multiple_Async_Upload_And_Download_10Files_5MB_Each

    2 participants

    0