2016-04-22 66 views
1

我有下面的代碼在新4JNeo4j的任務已經取消

public async Task LinkVertices<TSource, TTarget>(Expression<Func<TSource, TTarget, bool>> join, string relationName) 
{ 
     string sourceName = typeof(TSource).Name; 
     string targetName = typeof(TTarget).Name; 

     var span = (int)TimeSpan.FromMinutes(20).TotalMilliseconds; 
     try 
     { 
      await client.Cypher 
       .Match(string.Format("({0}:{0})", sourceName), string.Format("({0}:{0})", targetName)) 
       .Where(join) 
       .Create(string.Format("{0}-[:{2}]->{1}", sourceName, targetName, relationName)) 
       .MaxExecutionTime(span) 
       .ExecuteWithoutResultsAsync(); 


    } 

一般鏈接頂點當我聯繫較少的數據,其處理速度比它的工作原理

我設置MaxExecutionTime到20分鐘,但總是在100秒後,我得到了TaskCanceledException。 當我使用nonAsync Executemethod時,也會發生這種情況。

「正常」 堆棧跟蹤:

at Neo4jClient.GraphClient.Neo4jClient.IRawGraphClient.ExecuteCypher(CypherQuery query) in D:\temp\f6198f8\Neo4jClient\GraphClient.cs:line 1072 
    at Neo4jClient.Cypher.CypherFluentQuery.ExecuteWithoutResults() in D:\temp\f6198f8\Neo4jClient\Cypher\CypherFluentQuery.cs:line 392 
    at Graph.Neo4JGateway.<LinkVertices>d__3`2.MoveNext() in 

AsyncStack跟蹤:

at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) 
    at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) 
    at System.Threading.Tasks.Task`1.get_Result() 
    at Neo4jClient.GraphClient.<>c__86`1.<PrepareCypherRequest>b__86_1(Task`1 response) in D:\temp\f6198f8\Neo4jClient\GraphClient.cs:line 979 
    at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke() 
    at System.Threading.Tasks.Task.Execute() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Neo4jClient.GraphClient.<Neo4jClient-IRawGraphClient-ExecuteCypherAsync>d__90.MoveNext() in D:\temp\f6198f8\Neo4jClient\GraphClient.cs:line 1088 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.GetResult() 
    at Graph.Neo4JGateway.<LinkVertices>d__3`2.MoveNext() 

有另一種超時我失蹤?

回答

2

聽起來像它可能是HttpClient超時。默認有100秒。

如果您使用用戶名/密碼,那麼這將無法正常工作 - 我們得走下來一個稍微複雜的路線,但是如果你可以測試這個無需用戶名/密碼,然後我可以添加那。

var client = new GraphClient(new Uri("http://localhost.:7474/db/data"), 
    new HttpClientWrapper(
    new HttpClient() { Timeout = TimeSpan.FromMinutes(20)}) 
    ); 

我們正在傳遞一個自定義HttpClientWrapper實例這裏,與Timeout設置爲20分鐘。


編輯

剛纔檢查,我在LinqPad使用的是舊版本,更新,你可以與用戶的操作/傳:

var gc = new GraphClient(new Uri("http://localhost.:7474/db/data"), 
    new HttpClientWrapper("user", "pass", 
    new HttpClient() { Timeout = TimeSpan.FromMinutes(20)}) 
    ); 
+0

事實上,幫助! :) –