我使用Neo4jClient对Neo4j数据库进行了一个相当长的查询,并得到了一个非常随机发生的异常。如何解决这个问题?
System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Neo4jClient.GraphClient.<>c__DisplayClass3.<SendHttpRequestAsync>b__2(Task`1 requestTask) in c:\TeamCity\buildAgent\work\f1c4cf3efbf1b05e\Neo4jClient\GraphClient.cs:line 149
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Neo4jClient.GraphClient.<>c__DisplayClass1b`1.<Neo4jClient.IRawGraphClient.ExecuteGetCypherResultsAsync>b__1a(Task`1 responseTask) in c:\TeamCity\buildAgent\work\f1c4cf3efbf1b05e\Neo4jClient\GraphClient.cs:line 745
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Neo4jClient.GraphClient.<>c__DisplayClass3.<SendHttpRequestAsync>b__2(Task`1 requestTask) in c:\TeamCity\buildAgent\work\f1c4cf3efbf1b05e\Neo4jClient\GraphClient.cs:line 149
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
---> (Inner Exception #0) System.Threading.Tasks.TaskCanceledException: A task was canceled.<---
<---发布于 2013-04-02 11:18:43
这是https://bitbucket.org/Readify/neo4jclient/issue/70/taskcancelledexception的一个问题
诊断和最终的“官方”解决方案将张贴在那里。
发布于 2019-02-10 15:59:50
我花了几个小时来确定这个问题并解决它。
编辑:不要使用Neo4jClient.GraphClient,使用Neo4jClient.BoltGraphClient -两者都是从IGraphClient派生的- BoltGraphClient不会在幕后使用HttpClient,而且速度更快,占用的内存也更少。
var BoltGraphClient = new Neo4jClient.BoltGraphClient(url,username,password);
我以前的回答+故事:
我将大量的Cypher查询放到一个List<Task>中,并通过query.ExecuteWithoutResultsAsync()执行它们。Neo4j服务器一次只能处理这么多,并且会将请求放入队列中。
我已经确认了在100秒后抛出TaskCanceledException,这是HttpClient的默认超时。
在阅读了文档之后,我已经了解了如何在graphclient的初始化期间指定无限的时间跨度。希望这能节省你的时间。
var httpClientWrapper = new Neo4jClient.HttpClientWrapper(
username,
password,
new System.Net.Http.HttpClient() {
Timeout = System.Threading.Timeout.InfiniteTimeSpan
});
var graphClient = new Neo4jClient.GraphClient(new Uri(url), httpClientWrapper);https://stackoverflow.com/questions/15702544
复制相似问题