Select to view content in your preferred language

QueryTask fails with large feature count

10-26-2015 09:42 AM
New Contributor II

After increasing LocalMapService.MaxRecords to 100,000 (from default 1000) to get all features for a particular sub-layer, I'm now getting an exception with the following message when querying against a large featureSet:

"Cannot write more bytes to the buffer than the configured maximum buffer size: 104857600."  (0x6400000)

I need to be able to query all features for a particular layer/sub-layer. 

Where is this max buffer size defined?  Is there a way to increase this maximum buffer size through the API or maybe in a file somewhere?

2 Replies
Esri Contributor

I believe this exception is being raised by the underlying System.Net.Http.HttpClient used by the QueryTask.There's a solution to this error described here: .net - HttpClient buffer size limit exceeded - Stack Overflow, but it's only relevant if you have direct control over the HttpClient in your code (rather than going through the QueryTask, ie.).

I suspect your best approach might be to try to make the response as lean as possible. If you don't need the geometry for the features, for example, you could set ReturnGeometry = false. A good start might be to restrict the fields that are returned by the query by setting the Query.OutFields property to only those you'll need in your app. If you need additional information later (geometry or attributes for a specific feature, for example) you could re-query for the extra information (maybe using the ObjectID).

Regular Contributor II

The upper limit for the buffer should be 2147483647 (i.e. Maximum value for a variable of type int).  The default value will be most likely be the 104857600 value you're seeing.

HttpClient.MaxResponseContentBufferSize Property

I ran into this error once before while downloading some rather large mobile geodatabases from a feature service. In my code I instantiate the client as follows:

var client = new ArcGISHttpClient { MaxResponseContentBufferSize = 2147483647, Timeout = TimeSpan.FromMinutes(0.5) };