Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | SDKs | SDKs

Bug setting timeout in the RestSharpHttpClient in v1.2.1 .NET client

1 reply [Last post]
  • Login or register to post comments
Tue, 03/12/2013 - 00:01
parautenbach
Offline
Joined: 03/11/2013
Groups: None

We are using Couchbase views and have discovered a very aggressive timeout when the underlying web request executes in v1.2.1 of the .NET SDK:

----> System.Net.WebException : The request was aborted: The operation has timed out.
...
--WebException
    at Couchbase.RestSharpHttpClient.RestSharpResponseWrapper.ExecuteWith(RestClient client)
    at Couchbase.RestSharpHttpClient.RestSharpRequestWrapper.Couchbase.IHttpRequest.GetResponse()
    at Couchbase.CouchbaseViewHandler.GetResponse(IDictionary`2 viewParams)
    at Couchbase.CouchbaseViewHandler.<transformresults>d__0`1.MoveNext()

This timeout happens almost immediately, which was suspect. We're using the CouchbaseClientConfiguration class to configure the Couchbase client. A quick check revealed that the default timeout is set as follows:

public class CouchbaseClientConfiguration : ICouchbaseClientConfiguration
  {
    private Type nodeLocator;
    private ITranscoder transcoder;
    private IMemcachedKeyTransformer keyTransformer;
    private TimeSpan defaultHttpRequestTimeout = TimeSpan.FromMinutes(1);

This then gets consumed here:

public RestSharpHttpClient(Uri baseUri, string username, string password, TimeSpan timeout, bool shouldInitConnection)
  {
    client = new RestClient { BaseUrl = baseUri.ToString() };
    client.Timeout = timeout.Milliseconds;
    if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
    {
      client.Authenticator = new HttpBasicAuthenticator(username, password);
    }

The offending code is client.Timeout = timeout.Milliseconds; which should be client.Timeout = timeout.TotalMilliseconds;, otherwise one gets the millisecond portion, which will be 0. Even worse, you can partially work around it, but you can only set the timeout to at most 999ms, which, I'll grant, will be slow for a LAN. When using an App.config and the appropriate configuration section, this seems to be set correctly, but we're using a centralised configuration system and not the App.config.

Top
  • Login or register to post comments
Fri, 03/22/2013 - 07:20
john
Offline
Joined: 01/05/2012
Groups: None

Thanks for bringing this bug to my attention, and for your detailed analysis. I've opened a ticket at http://www.couchbase.com/issues/browse/NCBC-239. I've submitted the patch and the fix will be part of the 1.2.4 release the first week of April. A verification build is attached to the ticket. Apologies for the inconvenience...

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker