Splunk Search

Why does the C# SDK 2.0 only work when a query produces results?

bld7262
New Member

Perhaps similar to:

https://answers.splunk.com/answers/206372/enumerating-empty-searchresultstream-causes-invali-1.html

When I do:

var job = await Service.Jobs.CreateAsync(searchString);
using (var stream = await job.GetSearchResultsAsync())
...

I get the modal window for:

Debug.Assert(reader.NodeType == XmlNodeType.EndElement && reader.Name == "results", "Expected: ");

(here, NodeType is None and reader.Name = "")

From:
ReadMetadataAsync()

In:
Splunk.Client.SearchResultStream

And it is in an infinite loop with for (;;).

Again, everything works fine when the query produces results.

0 Karma

jtacy
Builder

Glad you found a fix! Noticed that this sounds very similar to https://github.com/splunk/splunk-sdk-csharp-pcl/issues/54 and it looks like a patch has been committed for it. I'm assuming that the patch might be included in a future release so it might be worth testing to see if it covers your specific scenario.

0 Karma

bld7262
New Member

I seemed to create a temporary fix.

In async Task ReadMetadataAsync()

Changed:
if (metadata.FieldNames.Count > 0)

To:
if (metadata.FieldNames.Count > 0 || reader.NodeType == XmlNodeType.None)

Not sure why the server is not returning an empty set when there are no results - something like a .

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...