Need help from the community. We are using Splunk Client for csharp, Splunk client version 2.2.9.0
on .net framework 4.5
After the Splunk version was upgraded to 8.1.4 we are getting the following exception.
Exception: “Value does not fall within the expected range.”
The code is as follows, the same code gets the search results for the same dataset for data prior to the Splunk version upgrade. I can provide stack trace if needed. Here is the code snippet
using Splunk.Client;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Net;
using System.Threading.Tasks;
namespace Integration_Service
{
class SplunkQueryManager
{
public static async Task<SplunkQueryManager.SplunkSearchResult> Get(String query, StreamWriter logfile, string server, string[] pwd)
{
logfile.WriteLine("Beginning Splunk Search at: " + DateTime.Now.ToString());
string job_id = "none";
try
{
SplunkSearchResult SearchInfo = new SplunkSearchResult();
using (var service = new Service(new Uri(server)))
{
//Login to Splunk
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
await service.LogOnAsync(pwd[0], pwd[1]);
//create job, set searchstream variable, and collect job ID
Job job = await service.Jobs.CreateAsync(query);
await job.SetTtlAsync(60);
SearchResultStream stream;
job_id = job.Sid;
SearchInfo.SplunkSearchID = job_id;
// The next line caused the exception
using (stream = await job.GetSearchResultsAsync())
{
//count number of results for future reference
SearchInfo.EventCount = job.EventCount;
//log search ID
logfile.WriteLine("Getting events from Splunk Search: " + SearchInfo.SplunkSearchID);
SearchInfo.Data = GetDataFromStream(stream);
//log success
logfile.WriteLine("Splunk Search: " + SearchInfo.SplunkSearchID + " returned " + SearchInfo.EventCount + " events at: " + DateTime.Now.ToString());
await job.RemoveAsync();
SearchInfo.error = "no";
return SearchInfo;
}
}
}
catch (Exception e)
{
//log errors
logfile.WriteLine("Splunk search failed at: " + DateTime.Now.ToString());
logfile.WriteLine("SearchResults error: \r\n" + e);
logfile.WriteLine("Results not returned for Splunk Search: " + job_id + " at: " + DateTime.Now.ToString());
SplunkSearchResult searchError;
searchError.Data = new List<Dictionary<string, string>>();
searchError.SplunkSearchID = job_id;
searchError.EventCount = 0;
searchError.error = "yes";
System.Threading.Thread.Sleep(30000);
return searchError;
}
}
Need help from the community. We are using Splunk Client for csharp, Splunk client version 2.2.9.0 on .net framework 4.5 After the Splunk version was upgraded to 8.1.4 we are getting the following exception. Exception: “Value does not fall within the expected range.” The code is as follows, the same code gets the search results for the same dataset for data prior to the Splunk version upgrade. I can provide stack trace if needed. Here is the code snippet