2

I've the following code to generically link vertices in neo 4j

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();


    }

When I link less data which is handled faster than it works

I set the MaxExecutionTime to 20 Minutes but always after 100 seconds I got a TaskCanceledException. This also happens When I Use the nonAsync Executemethod.

"Normal" StackTrace:

   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 Trace:

   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()

Is there another timeout i'm missing ?

Boas Enkler
  • 12,264
  • 16
  • 69
  • 143

1 Answers1

3

Sounds like it could be the HttpClient timing out. The default there is 100 seconds.

If you're using a user/pass, then this won't work - and we'll have to go down a slightly more complex route, but if you can test this without user/pass, then I can add that.

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

We're passing in a custom HttpClientWrapper instance here, with the Timeout set to 20 mins.


EDIT

Just checked, and I was using an old version in LinqPad, updated, and you can do this with user/pass:

var gc = new GraphClient(new Uri("http://localhost.:7474/db/data"), 
    new HttpClientWrapper("user", "pass", 
    new HttpClient() { Timeout = TimeSpan.FromMinutes(20)})
    );
Charlotte Skardon
  • 6,220
  • 2
  • 31
  • 42