远程Libgit2是否超时

时间:2014-02-05 09:19:44

标签: libgit2 libgit2sharp

当我将一个大型存储库推送到遥控器时,我遇到了超时异常。

如何设置远程超时?

更新

错误消息

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

我的代码

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();
    }
}

回购规模

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

同时,我的基于ASP.NET MVC的git服务器出现异常

System.Web.HttpException (0x80004005) ---> System.Web.HttpException (0x80070057): The remote host closed the connection. The error code is 0x80070057.

1 个答案:

答案 0 :(得分:2)

该超时来自WinHttpReceiveResponse(); MSDN建议默认值是30秒,这是令人遗憾的低。

目前无法将超时传递给传输。我想我们必须在某个时候添加它。