2014-02-05 67 views
0

当我将大型资源库推送到远程时,出现超时异常。远程执行Libgit2sharp超时

如何设置远程的超时时间?

UPDATE:

错误信息

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 

在同一时间,我的A SP.NET基于MVC的Git服务器有一个例外

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

如果您正在推送,而不仅仅是尝试连接,那么超时不应该发生在libgit2中。你会得到什么确切的错误?谁发送它? –

回答

2

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

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

+0

@Aimeast如果超时值对你来说感觉是个好主意,也许在libgit2中值得** [打开功能请求](https://github.com/libgit2/libgit2/issues/new)**问题跟踪器? – nulltoken