Question

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.
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top