Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial client error 255 and HTTP error 404 when attempting to push large files to server

Problem:

19/06/10 Update: More evidence problem is server-side. Receiving this error on Windows 7 command line (see below for full traceback):

URLError: <urlopen error [Errno 10054] An existing connection was forcibly closed by the remote host>     abort: error: An existing connection was forcibly closed by the remote host 

When attempting to push a changeset that contains 6 large files (.exe, .dmg, etc) to my remote server my client (MacHG) is reporting the error:

"Error During Push. Mercurial reported error number 255: abort: HTTP Error 404: Not Found"

What does the error even mean?! The only thing unique (that I can tell) about this commit is the size, type, and filenames of the files. How can I determine which exact file within the changeset is failing? How can I delete the corrupt changeset from the repository? In a different post, someone reported using "mq" extensions to effectively delete an erroneous changeset from the history within a repository, but mq looks overly complicated for what I'm trying to solve.


Background:

I can push and pull the following: source files, directories, .class files and a .jar file to and from the server, using both MacHG and toirtoise HG.

I successfully committed to my local repository the addition for the first time the 6 large .exe, .dmg etc installer files (about 130Mb total).

In the following commit to my local repository, I removed ("untracked" / forget) the 6 files causing the problem, however the previous (failing) changeset is still queued to be pushed to the server (i.e. my local host is trying to push the "add" and then the "remove" to the remote server - and keep aligned with the "keep everything in history" philosophy of the source control system).

I can commit .txt .java files etc using TortoiseHG from Windows PCs. I haven't actually testing committing or pushing the same large files using TortoiseHG.

Please help!


Setup:

Client applications = MacHG v0.9.7 (SCM 1.5.4), and TortoiseHG v1.0.4 (SCM 1.5.4)

Server = HTTPS, IIS7.5, Mercurial 1.5.4, Python 2.6.5, setup using these instructions:

http://www.jeremyskinner.co.uk/mercurial-on-iis7/

In IIS7.5 the CGI handler is configured to handle ALL verbs (not just GET, POST and HEAD).

My hgweb.cgi file on the server is as follows:

#!/usr/bin/env python # # An example hgweb CGI script, edit as necessary  # Path to repo or hgweb config to serve (see 'hg help hgweb') #config = "/path/to/repo/or/config"  # Uncomment and adjust if Mercurial is not installed system-wide: #import sys; sys.path.insert(0, "/path/to/python/lib")  # Uncomment to send python tracebacks to the browser if an error occurs: #import cgitb; cgitb.enable()  from mercurial import demandimport; demandimport.enable() from mercurial.hgweb import hgweb, wsgicgi application = hgweb('C:\inetpub\wwwroot\hg\hgweb.config') wsgicgi.launch(application) 

My hgweb.config file on the server is as follows:

[collections] C:\Mercurial Repositories = C:\Mercurial Repositories  [web] baseurl = /hg allow_push = usernamea allow_push = usernameb 

Output from the command line from my macbook (both Mercurial and MacHG installed) using -v and --trackback flags:

macbook15:hgrepos coderunner$ hg -v --traceback push pushing to https://coderunner:***@hg.mydomain.com.au/hg/hgrepos searching for changes 3 changesets found Traceback (most recent call last):   File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 50, in _runcatch     return _dispatch(ui, args)   File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 471, in _dispatch     return runcommand(lui, repo, cmd, fullargs, ui, options, d)   File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 341, in runcommand     ret = _runcommand(ui, options, cmd, d)   File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 522, in _runcommand     return checkargs()   File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 476, in checkargs     return cmdfunc()   File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 470, in <lambda>     d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)   File "/Library/Python/2.6/site-packages/mercurial/util.py", line 401, in check     return func(*args, **kwargs)   File "/Library/Python/2.6/site-packages/mercurial/commands.py", line 2462, in push     r = repo.push(other, opts.get('force'), revs=revs)   File "/Library/Python/2.6/site-packages/mercurial/localrepo.py", line 1491, in push     return self.push_unbundle(remote, force, revs)   File "/Library/Python/2.6/site-packages/mercurial/localrepo.py", line 1636, in push_unbundle     return remote.unbundle(cg, remote_heads, 'push')   File "/Library/Python/2.6/site-packages/mercurial/httprepo.py", line 235, in unbundle     heads=' '.join(map(hex, heads)))   File "/Library/Python/2.6/site-packages/mercurial/httprepo.py", line 134, in do_read     fp = self.do_cmd(cmd, **args)   File "/Library/Python/2.6/site-packages/mercurial/httprepo.py", line 85, in do_cmd     resp = self.urlopener.open(req)   File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 389, in open     response = meth(req, response)   File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 502, in http_response     'http', request, response, code, msg, hdrs)   File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 427, in error     return self._call_chain(*args)   File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 361, in _call_chain     result = func(*args)   File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 510, in http_error_default     raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) HTTPError: HTTP Error 404: Not Found abort: HTTP Error 404: Not Found macbook15:hgrepos coderunner$  

Output from Windows 7 host (has only TortoiseHG installed) attempting to push the same files to the server (different changset, but contains the same 6 file additions as the changeset being pushed from the macbook)

c:\repositories\hgrepos>hg -v --traceback push pushing to https://coderunner:***@hg.mydomain.com.au/hg/hgrepos searching for changes 1 changesets found Traceback (most recent call last):   File "mercurial\dispatch.pyo", line 50, in _runcatch   File "mercurial\dispatch.pyo", line 471, in _dispatch   File "mercurial\dispatch.pyo", line 341, in runcommand   File "mercurial\dispatch.pyo", line 522, in _runcommand   File "mercurial\dispatch.pyo", line 476, in checkargs   File "mercurial\dispatch.pyo", line 470, in <lambda>   File "mercurial\util.pyo", line 401, in check   File "mercurial\commands.pyo", line 2462, in push   File "mercurial\localrepo.pyo", line 1491, in push   File "mercurial\localrepo.pyo", line 1636, in push_unbundle   File "mercurial\httprepo.pyo", line 235, in unbundle   File "mercurial\httprepo.pyo", line 134, in do_read   File "mercurial\httprepo.pyo", line 85, in do_cmd   File "urllib2.pyo", line 389, in open   File "urllib2.pyo", line 407, in _open   File "urllib2.pyo", line 367, in _call_chain   File "mercurial\url.pyo", line 523, in https_open   File "mercurial\keepalive.pyo", line 259, in do_open URLError: <urlopen error [Errno 10054] An existing connection was forcibly closed by the remote host> abort: error: An existing connection was forcibly closed by the remote host  c:\repositories\hgrepos> 

It is a keep-alive issue? Is IIS7.5 at fault? Python 2.6.5 at fault?

like image 268
coderunner Avatar asked Jun 18 '10 09:06

coderunner


1 Answers

Went through the same pain points...

With the default settings on the IIS server, you will not be able to push large repositories to the server, as IIS has a default maximum request length of only 4 MB, and a timeout for CGI scripts of 15 min, making it impossible to upload large files. To enable the uploading of large files (and this is not easy to find on the web…), do the following:
1. In IIS Manager, click on the web site node, and click the Limits… link.
2. Then specify a connection time-out sufficiently large (I chose 1 hour here, or 3600 seconds)
3. Next, click the node containing hg (as per the installation procedure), then double-click CGI
4. Specify a sufficiently-long time out for CGI scripts (e.g., 10 hours)

Now, edit C:\inetpub\wwwroot\hg\web.config, so that it has a new <security> section under <system.webserver>, and a <httpRuntime> specification under <system.web>:

<?xml version="1.0" encoding="UTF-8"?> <configuration>   <system.webServer> […]     <security>          <requestFiltering>            <requestLimits maxAllowedContentLength ="2147482624" />       </requestFiltering>     </security>   </system.webServer>   <system.web>     <httpRuntime       executionTimeout="540000" maxRequestLength="2097151"/>   </system.web> </configuration> 

This specifies an http timeout of a bit more than 6 days, and a maximum upload limit of about 2 GB.

like image 170
marcslogic Avatar answered Sep 22 '22 16:09

marcslogic