.NET Timeout at 75 seconds, QueryRequestTimeout not working

I keep getting a timeout even with the QueryRequestTimeout set. How do I prevent this timeout?
thanks

.NET SDK 2.5.9
Couchbase 5.1

            ClientConfiguration.UseInterNetworkV6Addresses = false;
            var couchBasecConfig = new ClientConfiguration
            {
                Servers = clusterUrl.Split(';').Select(url => new Uri(url.Trim())).ToList(),
                UseSsl = false,
                QueryRequestTimeout = int.MaxValue,
                SearchRequestTimeout = int.MaxValue,
                PoolConfiguration = new PoolConfiguration()
                {
                    MaxSize = maxPoolSize,
                    MinSize = minPoolSize,

@dsullivan -

The ClientConfiguration.QueryRequestTimeout sets the client side timeout for a query; the server side timeout can be configured by the QueryRequest.Timeout(Timespan) method on a per request basis. Can you post the code where you execute the query ( I am assuming this is a N1QL query)? Additionally, post any information returned by the Exception, Errors and Message fields in the response. Finally, try enabling logging to get a better idea of what is going on.

-Jeff

@jmorris -
Yes, it’s a N1QL query which takes a minute 40 seconds to run in Couchbase admin query console. Below is the Query Execution code where queryResult.Success == false and queryResult.Errors is empty, queryResult.HttpStatusCode == BadRequest, queryResult.Status == Fatal, so it ends up throwing the CouchbaseQueryResponseException…

        var query = QueryRequest.Create(queryString);
        query.Timeout(new TimeSpan(0, 20, 0));  // 20 minutes
        query.ReadOnly(readOnly);

        if (parameters != null && parameters.Any())
        {
            foreach (var param in parameters)
            {
                query.AddNamedParameter(param.Key, param.Value);
            }
        }

        if (!canBeStale)
        {
            query.ScanConsistency(ScanConsistency.RequestPlus);
        }

        var queryResult = await this.Bucket.QueryAsync<T>(query).ConfigureAwait(false);
        if (!queryResult.Success)
        {
            var errors = new List<Error>();
            errors.AddRange(queryResult.Errors);
            throw new CouchbaseQueryResponseException("Error running N1QL query: " + query.ToString(), queryResult.Status, errors);
        }

        var returnedRecords = new List<T>();
        returnedRecords.AddRange(queryResult.Rows);

        var result = new CouchBaseQueryResultMessage<T>()
        {
            ReturnedRecords = returnedRecords,
            MutationCount = (int)queryResult.Metrics.MutationCount,
        };

        return result;

@dsullivan -

Based on what I see here (the QueryRequestTimeout and setting the Timeout method on the query), you should not be timing out here in 75 seconds. Can you use fiddler (or some other HTTP debugger) and post the HTTP POST request/response for debugging?

-Jeff

@jmorris -
I put some “hello world” code into a console application to isolate the couchbase call, what I found is… The synchronous call works as expected, but he async/await call does not. See the code below. The async call from Main is simply “var testResult = new CouchbaseTester().Test().GetAwaiter().GetResult();” (I left the 2 lines for the synchronous call in comments so you can switch it to see the difference)
Looks like the async/await call simply ignores the QueryRequestTimeout setting.
Are you able to reproduce this?
thanks for your time!

using Couchbase;
using Couchbase.Configuration.Client;
using Couchbase.Core;
using Couchbase.N1QL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CouchbaseConsole
{
    public class CouchbaseTester
    {
        public ICluster CouchBaseCluster { get; protected set; }
        public async Task<int> Test()
//        public int Test()
        {
            InitCluster();

            try
            {
                var bucket = this.GetBucket();
                string query = "SELECT `b`.* FROM `myBucket` b... some query that takes 2 minutes to execute";
                var queryRequest = QueryRequest.Create(query);
                queryRequest.Timeout(new TimeSpan(0, 20, 0));  // 20 minutes

                var queryResult = await bucket.QueryAsync<dynamic>(queryRequest).ConfigureAwait(false);
//                var queryResult = bucket.Query<dynamic>(queryRequest);

                if (!queryResult.Success)
                {
                    var errors = new List<Error>();
                    errors.AddRange(queryResult.Errors);
                    // throw Exception
                }

                var returnedRecords = new List<dynamic>();
                returnedRecords.AddRange(queryResult.Rows);

                Console.WriteLine("Press Enter...");
                Console.Read();

            }
            catch (Exception ex)
            {
                string msg = ex.Message;
            }

            return 5;
        }

        private IBucket GetBucket()
        {
            Couchbase.Core.IBucket bucket;
            bucket = this.CouchBaseCluster.OpenBucket("myBucket", "myPassword");
            return bucket;
        }

        private void InitCluster ()
        {
            try
            {
                this.CouchBaseCluster = ClusterHelper.Get();
            }
            catch (InitializationException)
            {
                ClientConfiguration.UseInterNetworkV6Addresses = false;
                var couchBasecConfig = new ClientConfiguration
                {
                    Servers = "http://someserver:8091/pools".Split(';').Select(url => new Uri(url.Trim())).ToList(),
                    UseSsl = false,

                    PoolConfiguration = new PoolConfiguration()
                    {
                        MaxSize = 10,
                        MinSize = 1,
                    }
                };

                couchBasecConfig.QueryRequestTimeout  = 1555000;
                ClusterHelper.Initialize(couchBasecConfig);
                this.CouchBaseCluster = ClusterHelper.Get();
            }
        }
    }
}