<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: C# API Query TImeOut in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/C-API-Query-TImeOut/m-p/79581#M16320</link>
    <description>&lt;P&gt;Chunking the result set should be a good approach. There's first class support for this in Splunk REST API. Refer to 'count' and 'offset' parameters of &lt;/P&gt;

&lt;P&gt;GET search/jobs/{search_id}/results &lt;/P&gt;

&lt;P&gt;on &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.2/RESTAPI/RESTsearch#search.2Fjobs.2F.7Bsearch_id.7D.2Fresults"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.2/RESTAPI/RESTsearch#search.2Fjobs.2F.7Bsearch_id.7D.2Fresults&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Using C# SDK, you can supply the two parameters using Args object which is a dictionary of name and value pairs. Let me know if you have any questions on this.&lt;/P&gt;

&lt;P&gt;Btw, I am interested in exactly where it fails in your case now. So please send me any other info about the error if any.&lt;/P&gt;</description>
    <pubDate>Fri, 29 Mar 2013 20:29:57 GMT</pubDate>
    <dc:creator>ywu</dc:creator>
    <dc:date>2013-03-29T20:29:57Z</dc:date>
    <item>
      <title>C# API Query TImeOut</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/C-API-Query-TImeOut/m-p/79578#M16317</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I edited the c# splunk API search example and made it into the method below. It basically creates a connection then does a search and puts all the results into a list of csv. Which i use later.&lt;/P&gt;

&lt;P&gt;the problem i am having is if the search takes a while to run, the connection gets closed so when i to too read each line from the stream i get an error saying "The request was aborted".&lt;/P&gt;

&lt;P&gt;is there a way to set the timeout value?&lt;/P&gt;

&lt;P&gt;or can i create the search, wait for it to finish, then re-connect to pull down the results.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   public static List&amp;lt;string&amp;gt; SplunkSearch(string strQuery)
    {
        var cli = Command.Splunk("search");
        cli.AddRule("search", typeof(string), "search string");

        cli.Opts.Add("host", "host");
        cli.Opts.Add("port", "8089");
        cli.Opts.Add("scheme", "https");
        cli.Opts.Add("username", "uname");
        cli.Opts.Add("password", "pwd");
        cli.Opts.Add("search",strQuery);
        cli.Opts.Add("Timeout", "1000");

        var service = Service.Connect(cli.Opts);

        var jobs = service.GetJobs();
        var job = jobs.Create((string)cli.Opts["search"]);

        while (!job.IsDone)
        {
            Thread.Sleep(1000);
        }



        var outArgs = new Args
        {
            { "output_mode", "csv" },

            // Return all entries.
            { "count", "0" }
        };
        int intRun = 0;
        string columnnames = "";
        List&amp;lt;string&amp;gt; lstResults = new List&amp;lt;string&amp;gt;();
        using (var stream = job.Results(outArgs))
        {
            using (StreamReader reader = new StreamReader(stream))
            {
                while (!reader.EndOfStream)
                {
                    lstResults.Add(reader.ReadLine());
                }
            }
        }

        return lstResults;
    }
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Mar 2013 18:49:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/C-API-Query-TImeOut/m-p/79578#M16317</guid>
      <dc:creator>michaudel</dc:creator>
      <dc:date>2013-03-29T18:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: C# API Query TImeOut</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/C-API-Query-TImeOut/m-p/79579#M16318</link>
      <description>&lt;P&gt;In your code, at the time the stream is read, search has finished already. It is a separate httpwebrequest to get the result. It is essentially what you said -- "wait for it to finish, then re-connect to pull down the results."&lt;/P&gt;

&lt;P&gt;Do you have to more detailed info to share?&lt;/P&gt;

&lt;P&gt;What many lines are there in the search result? &lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2013 19:27:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/C-API-Query-TImeOut/m-p/79579#M16318</guid>
      <dc:creator>ywu</dc:creator>
      <dc:date>2013-03-29T19:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: C# API Query TImeOut</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/C-API-Query-TImeOut/m-p/79580#M16319</link>
      <description>&lt;P&gt;Thank you for the explanation on the http request part. I think you are on to something, i think it is the size of result that is getting me. When i run a long query, but bucket into hour of day (so 24 results) it works even though the query took 5 mins. If I run another query which returns about 10K results,it aborts the connection. I am guessing i  need to chunk my result set. Ask for 1K at a time or something?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2013 19:59:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/C-API-Query-TImeOut/m-p/79580#M16319</guid>
      <dc:creator>michaudel</dc:creator>
      <dc:date>2013-03-29T19:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: C# API Query TImeOut</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/C-API-Query-TImeOut/m-p/79581#M16320</link>
      <description>&lt;P&gt;Chunking the result set should be a good approach. There's first class support for this in Splunk REST API. Refer to 'count' and 'offset' parameters of &lt;/P&gt;

&lt;P&gt;GET search/jobs/{search_id}/results &lt;/P&gt;

&lt;P&gt;on &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.2/RESTAPI/RESTsearch#search.2Fjobs.2F.7Bsearch_id.7D.2Fresults"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.2/RESTAPI/RESTsearch#search.2Fjobs.2F.7Bsearch_id.7D.2Fresults&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Using C# SDK, you can supply the two parameters using Args object which is a dictionary of name and value pairs. Let me know if you have any questions on this.&lt;/P&gt;

&lt;P&gt;Btw, I am interested in exactly where it fails in your case now. So please send me any other info about the error if any.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2013 20:29:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/C-API-Query-TImeOut/m-p/79581#M16320</guid>
      <dc:creator>ywu</dc:creator>
      <dc:date>2013-03-29T20:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: C# API Query TImeOut</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/C-API-Query-TImeOut/m-p/79582#M16321</link>
      <description>&lt;P&gt;Please take a look at:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://splunk-base.splunk.com/answers/93382/timeout-error-in-resultsreaderxml-c-sdk-example-search-program"&gt;http://splunk-base.splunk.com/answers/93382/timeout-error-in-resultsreaderxml-c-sdk-example-search-program&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;It might be the same issue.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2013 16:07:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/C-API-Query-TImeOut/m-p/79582#M16321</guid>
      <dc:creator>ywu</dc:creator>
      <dc:date>2013-07-29T16:07:03Z</dc:date>
    </item>
  </channel>
</rss>

