TotoiseHG: An existing connection was forcibly closed by the remote host
Asked Answered
S

4

6

I wanted to push a project from from TortoiseHg to GitHub. I know that, TortoiseHg is a front-end to the Mercurial distributed version control system; where GitHub works with Git. But I love to use TortoiseHg (instead of TortoiseGit or GitGui), and want to keep my project in GitHub.

So, I configured TortoiseHg (File>Settings>Extensions>hggit) and was able to push a test project to GitHub (following this wonderful blog). But later when I tried to push a C# MVC project with it, situation changed. It nicely starts pushing, then asks for authentication, & then shows this error-

An existing connection was forcibly closed by the remote host

Here is what shown in the log-

% hg push git+https://github.com/MinhasKamal/MVCPracticeWork
pushing to git+https://github.com/MinhasKamal/MVCPracticeWork
http authorization required for https://github.com/MinhasKamal/MVCPracticeWork/info/refs
realm: GitHub
searching for changes
adding objects
URLError: [Errno 10054] An existing connection was forcibly closed by the remote host
[command returned code 255 Thu Feb 04 16:17:02 2016]

I don't understand- why this error is happening. Is this a problem of GitHub or TortoiseHG, or I did something wrong? How it can be solved?


Edit 1: I am able to push to the repository but only by 'not adding' some specific directories to my repository. Is it any file type or name that is making this error?


Edit 2: The problem again happened with me, this time with a Java project. Everything was fine, till I added a *.jar file in the repository. I made a commit, but when I tried to push it to the GitHub, TortoiseHg showed me the same message. I removed the *.jar, committed, and tried to push again, but couldn't.

Now, I did again that I did before (Edit 1)- I pulled the whole repository from GitHub to another folder, replaced changed files from the current repository at my PC (did not add the *.jar), committed, and pushed; I was successful this time. So, this time the *jar file was not added to the version control database, that is why it worked.

Scab answered 4/2, 2016 at 10:30 Comment(26)
Your version of THG and hg-git have to be shown, maybe they are ancient as mammoth's bullshitNikolas
Are you behind a proxy? (as in https://mcmap.net/q/1775128/-mercurial-on-windows-abort-error-an-existing-connection-was-forcibly-closed-by-the-remote-host/6309)Marilou
@Marilou I am not sure, may be I am not behind any proxy.Scab
I don't think you are actually, since you can push without certain filesMarilou
What version of TortoiseHg, and git are you using?Marilou
@Marilou TortoiseHg version is- 3.6.3, Mercurial- 3.6.3, Qt- 4.8.6. I am pushing Mercurial repository to GitHub using an add-in hg-git. So, git version should be the latest.Scab
OK. I was reading support.hglabhq.com/discussions/problems/…, but that was 3 years ago.Marilou
@Marilou And my file size was only 380kb.Scab
Can you check if you have a mercurial.ini in your user directory (%USERPROFILE% if you are on Windows) as in https://mcmap.net/q/1775129/-can-39-t-push-pull-from-mercurial-repository-abort-error-an-existing-connection-was-forcibly-closed-by-the-remote-host? (or https://mcmap.net/q/1775128/-mercurial-on-windows-abort-error-an-existing-connection-was-forcibly-closed-by-the-remote-host)Marilou
@Marilou Yes, I have. Should I delete it? Here is the content- [extensions] \n hggit = \n eol= \n [ui] \n username=MinhasKamal <[email protected]> \n [auth] \n github.com.prefix = github.com \n github.com.username = MinhasKamal \nScab
OK, so no proxy entry there, you can leave it as is.Marilou
Are you on Windows? Does your TortoiseHG uses IIS in any way? (as in https://mcmap.net/q/1775130/-https-for-mercurial-1-9-2-on-windows-server-2008-iis-7-giving-me-errno-10054)Marilou
@Marilou I am on Windows. I have VisualStudio in my PC, but IIS was not running. So, It should not be used by TSVN.Scab
Do you have git in your %PATH%? What git --version returns?Marilou
@Marilou I don't have Git installed in my PC. I don't know what happens while installing TortoiseHG, it should not install Git too. I do have EGit, which come with Eclipse, which cannot affect TortoiseHG.Scab
@MinhasKamal OK, so no local git needed here. Can you check if your current TortoiseHG-hggit would work better with python 2.7.x instead of python 3.x?Marilou
@Marilou How should I do that? Do you mean about the python installed in my PC? It is "Python 2.7.9rc1".Scab
@MinhasKamal 2.7 should be fine. Maybe the reverse could be tested, installing python 3.3? I am just searching what factor would cause such an error message.Marilou
@MinhasKamal Also, just for test, what would happen if you were to rename your jar file in myfile.jar.txt, and then push it?Marilou
@Marilou I renamed *.jar with *.txt extension, and I could not push. Then I renamed a *.png file to *.jar, but I could push. This is the repository.Scab
@MinhasKamal so in png, it is ok, not in jar or txt?Marilou
@Marilou I had a photo & I renamed it to *.jar, & it worked. So It is not file type rather file content that is causing the problem.Scab
@Marilou May be we could not figure out "how to solve the problem", but we were able to understand- "how we cannot solve it". Can't that be an answer too?Scab
@MinhasKamal I agree. I have added an answer summarizing the conclusions so far.Marilou
I'm having the exact problem you have, but your solution does not apply to me. I'm trying to push the exact same files from my local repository to a new GitHub repository and get the error. If I push to the old repo, no problem and if I make a new local repository, no problem, but I need to push existing commits to the new repo. It must be something with my local .hg folder.Internee
@MarkJeronimus The accepted answer does not give any solution, it simply addresses probable cause of the problem. If your are a fan of TortoiseHG, like me, but want to push in GitHub, then believe me, you are going to love SourceTree. I tried TortoiseGit, EGit, & GitGui; but SourceTree is the closest I got to TortoiseHG.Scab
M
2

So far, after many comments, it seems the content of some binary file types (like- *.jar, *.mp3 etc. but not *.png) are problematic:

  • not file size (although it the file was really large, that would be an issue too, but it is not here)
  • not its extension (the OP adds "I had a photo and I renamed it to *.jar, and it worked")

To keep a similar end-user experience, a test would be to install a TortoiseGit, and see if a git push would work in a classic git clone repo.

Marilou answered 17/4, 2016 at 11:0 Comment(9)
I also tried with other *.jar files, and it did not work. I tried also with *.mp3 file (a song), it did not work either. :(Scab
@MinhasKamal so a binary content seems to be systematically an issue.Marilou
Exactly. But not for image.Scab
@MinhasKamal I don't know Mercurial enough but I suspect some encoding issue which might affect the content of those file during transfer.Marilou
@MinhasKamal At this point, I would test cloning the repo with git (instead of hggit) elsewhere on your computer, add those problematic files, commit and see if the push works that way.Marilou
Yes, like- null or something.Scab
@MinhasKamal I have added a link to TortoiseGit, if you want to keep a similar GUI as TortoiseHg.Marilou
So, It seems like a TortoiseHG's hg-git extension issue, for certain types of binary files. There is also a slight possibility for GitHub issue too. I have changed your answer a bit, please verify if it is right.Scab
@MinhasKamal Thank you for the edit: the answer is clearer now.Marilou
N
2
  • I can't see any pushes to MinhasKamal/MVCPracticeWork: This repository is empty.
  • You can automate pushing process (no handwork, no timeouts, no input errors) using [auth] section in .hgrc of this repo (define username and password in it)
  • At least some initial test-pushes will be better to perform in pure CLI (more informative and readable output)
Nikolas answered 5/2, 2016 at 5:17 Comment(4)
You cannot see any push cause- I could not. I tested push in repository- github.com/MinhasKamal/test. I was also able to push in repository- github.com/MinhasKamal/Egami a few minutes ago. So, there should not be any problem in version. Thanks a lot for your response. :)Scab
@MinhasKamal - with hg push -v --debug you can see a lot of useful (?) dataNikolas
Where should I write this (hg push -v --debug) command in TortoiseHG?Scab
@MinhasKamal - out of ideas. I said about command-line and resolving your real problemNikolas
O
2

There is a problem with Github if you trying to add a super large file into any repo. Even though i don't know if that's your problem.

I had a change to commit with both HG and Git on my Mac and try to push it to github. Git shown me the file is too large message when I ran git push but HG only shown me push failed.

If your .jar or any of the file you added cause the problem, you can check if the file size excess the limit (from github) and this one

Operculum answered 15/4, 2016 at 20:31 Comment(2)
Thanks a lot, that link was really informative. But my *.jar file sized less than 500kb.Scab
Sorry that's not helpful. Maybe that's some other reason? Hope you find answer asapOperculum
M
2

So far, after many comments, it seems the content of some binary file types (like- *.jar, *.mp3 etc. but not *.png) are problematic:

  • not file size (although it the file was really large, that would be an issue too, but it is not here)
  • not its extension (the OP adds "I had a photo and I renamed it to *.jar, and it worked")

To keep a similar end-user experience, a test would be to install a TortoiseGit, and see if a git push would work in a classic git clone repo.

Marilou answered 17/4, 2016 at 11:0 Comment(9)
I also tried with other *.jar files, and it did not work. I tried also with *.mp3 file (a song), it did not work either. :(Scab
@MinhasKamal so a binary content seems to be systematically an issue.Marilou
Exactly. But not for image.Scab
@MinhasKamal I don't know Mercurial enough but I suspect some encoding issue which might affect the content of those file during transfer.Marilou
@MinhasKamal At this point, I would test cloning the repo with git (instead of hggit) elsewhere on your computer, add those problematic files, commit and see if the push works that way.Marilou
Yes, like- null or something.Scab
@MinhasKamal I have added a link to TortoiseGit, if you want to keep a similar GUI as TortoiseHg.Marilou
So, It seems like a TortoiseHG's hg-git extension issue, for certain types of binary files. There is also a slight possibility for GitHub issue too. I have changed your answer a bit, please verify if it is right.Scab
@MinhasKamal Thank you for the edit: the answer is clearer now.Marilou
U
2

This problem only occurs when you use the HTTPS protocol. If you use SSH instead (which is awkward, but nevertheless possible on Windows) the push will succeed.

See https://www.mercurial-scm.org/pipermail/mercurial/2017-March/050304.html for more info. I suggest reading the whole thread, which is only six messages.

Uprise answered 22/6, 2017 at 17:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.