0

I got a timeout exception when I push a big repository to a remote.

How to set the timeout for remote?

UPDATE:

error message

LibGit2Sharp.LibGit2SharpException: An error was raised by libgit2. Category = Invalid (Error).
Failed to receive response: The operation timed out

   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
   at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
   at LibGit2Sharp.Core.Proxy.git_push_finish(PushSafeHandle push)
   at LibGit2Sharp.Network.Push(Remote remote, IEnumerable`1 pushRefSpecs, PushOptions pushOptions)
   at LibGit2Sharp.Network.Push(Remote remote, String pushRefSpec, PushOptions pushOptions)
   at ConsoleApplication1.Program.Main(String[] args) in xxxx\Program.cs:line 52

My code

using (var repo = new Repository(@"path\to\local"))
{
    try
    {
        var remote = repo.Network.Remotes["VM"]
            ?? repo.Network.Remotes.Add("VM", @"https://path/to/remote");
        repo.Network.Push(remote, @"refs/heads/develop");
    }
    catch (Exception ex)
    {
        var str = ex.ToString();
    }
}

Repo size

$ git count-objects -v
count: 0
size: 0
in-pack: 14389
packs: 1
size-pack: 12138
prune-packable: 0
garbage: 0
size-garbage: 0

At same time, my ASP.NET MVC based git server got an exception

System.Web.HttpException (0x80004005) ---> System.Web.HttpException (0x80070057): The remote host closed the connection. The error code is 0x80070057.
Aimeast
  • 1,609
  • 14
  • 29
  • 1
    If you *are* pushing, and not just trying to connect, then the timeout shouldn't be happening in libgit2. What exact error do you get? who sends it? – Carlos Martín Nieto Feb 05 '14 at 11:55

1 Answers1

2

That timeout comes from WinHttpReceiveResponse(); MSDN suggests that the default value for this is 30 seconds, which is regrettably low.

There is currently no way to pass a timeout to the transports. I suppose we'll have to add it at some point.

Carlos Martín Nieto
  • 5,207
  • 1
  • 15
  • 16
  • @Aimeast If the timeout value feels like a good idea to you, maybe would it be worth **[opening a feature request](https://github.com/libgit2/libgit2/issues/new)** in the libgit2 issue tracker? – nulltoken Feb 08 '14 at 14:01