Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#Neo4jClient任务已取消异常_C#_Exception_Neo4j_Neo4jclient - Fatal编程技术网

C#Neo4jClient任务已取消异常

C#Neo4jClient任务已取消异常,c#,exception,neo4j,neo4jclient,C#,Exception,Neo4j,Neo4jclient,我使用Neo4jClient对Neo4j数据库进行了很长的查询,得到了一个非常随机的异常。如何解决这个问题 System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.

我使用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.<---
<---
System.AggregateException:发生一个或多个错误。-->System.AggregateException:发生一个或多个错误。-->System.Threading.Tasks.TaskCanceledException:任务已取消。
---内部异常堆栈跟踪的结束---
位于System.Threading.Tasks.Task`1.GetResultCore(布尔waitCompletionNotification)
在c:\TeamCity\buildAgent\work\f1c4cf3efbf1b05e\Neo4jClient\GraphClient.c_u中显示Class3.b_u2(任务'1 requestTask'):第149行
位于System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
在System.Threading.Tasks.Task.Execute()中
---内部异常堆栈跟踪的结束---
位于System.Threading.Tasks.Task`1.GetResultCore(布尔waitCompletionNotification)
在Neo4jClient.GraphClient.c__中,在c:\TeamCity\buildAgent\work\f1c4cf3efbf1b05e\Neo4jClient\GraphClient.cs:第745行中显示Class1B`1.b_1a(任务`1响应任务)
位于System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
在System.Threading.Tasks.Task.Execute()中
--->(内部异常#0)System.AggregateException:发生一个或多个错误。-->System.Threading.Tasks.TaskCanceledException:任务已取消。
---内部异常堆栈跟踪的结束---
位于System.Threading.Tasks.Task`1.GetResultCore(布尔waitCompletionNotification)
在c:\TeamCity\buildAgent\work\f1c4cf3efbf1b05e\Neo4jClient\GraphClient.c_u中显示Class3.b_u2(任务'1 requestTask'):第149行
位于System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
在System.Threading.Tasks.Task.Execute()中

--->(内部异常#0)System.Threading.Tasks.TaskCanceledException:某个任务已取消。这是在上作为问题进行跟踪的


诊断和最终的“官方”解决方案将发布在那里。

我花了几个小时才发现并解决了这个问题

[编辑]:不要使用
Neo4jClient.GraphClient
,使用
Neo4jClient.BoltGraphClient
-两者都源于
IGraphClient
-BoltGraphClient不在后台使用HttpClient,速度更快,内存占用更少

var-BoltGraphClient=new Neo4jClient.BoltGraphClient(url、用户名、密码)

我的旧答案+故事:

我将大量的Cypher查询放入
列表
,并通过
query.ExecuteWithoutResultsAsync()
执行它们。Neo4j服务器一次只能处理这么多,并且会将请求放入队列中

我已经确认
TaskCanceledException
在100秒后抛出,这是
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);

您可以分享更多关于查询类型和图形复杂性的信息吗?似乎Neo4jClient可能会超时,因为查询需要很长时间才能完成。它非常复杂,需要几分钟才能完成。是的,客户机可能正在超时。但是,错误发生的时间并不一致。