2014-02-05 68 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