Search code examples
c#.netcouchbasenancysystem.net.sockets

Failing to load byte[] or base64 data in Couchbase using C# client


When trying to in/upsert a document using either byte[] or a base64 encoded string I'm getting an exception and a !result.Success

Specified argument was out of the range of valid values.
Parameter name: count

My document doesn't contain anything named count. This exception all carries an inner exception of

StackTrace

at System.Net.Sockets.SocketAsyncEventArgs.SetBufferInternal(Byte[] buffer, Int32 offset, Int32 count)   
at Couchbase.IO.Connection.Send(Byte[] buffer)   
at Couchbase.IO.Strategies.DefaultIOStrategy.Execute[T](IOperation`1 operation)  
...

This happens only when I include the field that has the base64 or byte[] (re-factored to try both). On a windows7 pro 64 bit machine using NancyFX as the frontend and Couchbase as the database.

I have been unable to find any 2.0 .Net SDK or 3.0.2 Server documentation that would lead my in the right direction and have reached out to the #couchbase IRC with no luck yet. There does seem to be any settings related to file size (the test data is a 26.7k png). Hopefully its something simple that I'm misunderstanding.


Solution

  • My team encountered the same problem, we described it thus on the #libcouchbase IRC channel:

    Using the 2.0 .Net Client code, we are unable to inset a record of more than 32K bytes, we receive the following error: "Specified argument was out of the range of valid values.\r\nParameter name: count"

    I got an immediate response:

    <jefe1> that is a bug fixed in 2.0.2 which will be released tomorrow [2/3/15]

    We independently resolved the issue by manually setting the buffer length:

    cluster.Configuration.PoolConfiguration.MaxSize =
        ConfigurationSettings.Instance.CouchbaseMaxConnections;
    cluster.Configuration.PoolConfiguration.BufferSize =
        ConfigurationSettings.Instance.CouchbaseBufferSizeBytes;
    

    (I don't know the exact settings the team used.)

    And, this is a link to the Couchbase checkin that describes and fixes the problem: https://github.com/couchbase/couchbase-net-client/commit/80ba3cfadc3aa8ba0dc889a16056252617628324