SSH clones fail with "WindowClosedException: Already closed"

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

Clones and fetches are very slow and fail with:

bstuart$ git clone ssh://git@localhost:7999/tagged/web.git
Cloning into 'web'...
remote: Counting objects: 1315343, done.
remote: Compressing objects: 100% (363726/363726), done.
Corrupted MAC on input. (396153/1315343), 398.21 MiB | 556.00 KiB/s   
Disconnecting: Packet corrupt
Write failed: Broken pipe
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

Stash stops and the following appears in the atlassian-stash.log if debug logging is enabled:

2015-11-03 10:20:00,366 DEBUG [ssh-scm-request-handler] @14VBBVLx599x110072x10 bstuart 10.15.11.22 SSH - git-upload-pack 'tagged/web.git' c.a.s.s.c.s.CachingSshUploadPackRequest [TAGGED/web[650]] Exception encountered while processing a git-upload-pack request
org.apache.sshd.common.channel.WindowClosedException: Already closed

Cause

  1. A known issue in the SSH library that Bitbucket uses, MINA SSH.
  2. The network is killing SSH connections early. 

Diagnose

Cause 1

Temporarily add the following to the ~/.ssh/config file. Create it if it doesn't exist.

Host stashhost
   LogLevel DEBUG3
   RekeyLimit 1K

If you receive the following in the output this is most likely related to BSERV-5472 - Getting issue details... STATUS .

Disconnecting: Protocol error: expected packet type 31, got 94

Cause 2

Remove any possibility that the network is closing the SSH connection early by reproducing the problem locally on the Stash Server. Clone directly to the Stash server with SSH to see if the clone is successful every time. 

Resolution

Resolution 1

BSERV-5472 - Getting issue details... STATUS

Upgrade to Bitbucket Server 3.6+ or follow the workarounds provided on the above page. 

Resolution 2

Something specific to the network is closing the Git connections. More troubleshooting will be necessary to determine where the termination occurs.

In previous cases we have seen that the timeout setting for any proxies in front of the application need to be increased sufficiently to allow the operation to complete.

If the above doesn't help and the issue needs to be further investigated, open a support ticket at https://support.atlassian.com and attach the SSH debug logging and a support zip with debug and profile logging. 

Last modified on Jan 5, 2017

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.