<?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: splunk java sdk connection to splunk failed in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46640#M620</link>
    <description>&lt;P&gt;Thankyou for the quick reply.Yes it was port number. I was trying to connect 8000. BUT there is one important mistake was there.:) HTTP server was not running on my machine.Now I have installed Apache http server and code is working fine. Thankyou..!!!&lt;/P&gt;</description>
    <pubDate>Tue, 27 Nov 2012 23:47:41 GMT</pubDate>
    <dc:creator>disha</dc:creator>
    <dc:date>2012-11-27T23:47:41Z</dc:date>
    <item>
      <title>splunk java sdk connection to splunk failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46638#M618</link>
      <description>&lt;P&gt;I have just installed the splunk-sdk and build it. trying to execute basic example of "connect to Splunk"&lt;BR /&gt;
&lt;A href="http://dev.splunk.com/view/SP-CAAAECX"&gt;http://dev.splunk.com/view/SP-CAAAECX&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;It is showing this error&lt;/P&gt;

&lt;P&gt;Sam@SamPC /cygdrive/c/splunk-sdk-java/splunk&lt;BR /&gt;
$ ls&lt;BR /&gt;
com  splunk.iml  splunk.jar  SplunkTest.class  SplunkTest.java  staticdocs.css&lt;/P&gt;

&lt;P&gt;Sam@SamPC /cygdrive/c/splunk-sdk-java/splunk&lt;BR /&gt;
$ javac SplunkTest.java&lt;/P&gt;

&lt;P&gt;Sam@SamPC /cygdrive/c/splunk-sdk-java/splunk&lt;BR /&gt;
$ java SplunkTest&lt;BR /&gt;
Exception in thread "main" java.lang.RuntimeException: Unrecognized SSL message, plaintext connection?&lt;BR /&gt;
        at com.splunk.HttpService.send(HttpService.java:312)&lt;BR /&gt;
        at com.splunk.Service.send(Service.java:1110)&lt;BR /&gt;
        at com.splunk.HttpService.post(HttpService.java:210)&lt;BR /&gt;
        at com.splunk.Service.login(Service.java:950)&lt;BR /&gt;
        at com.splunk.Service.connect(Service.java:150)&lt;BR /&gt;
        at SplunkTest.main(SplunkTest.java:19)&lt;/P&gt;

&lt;P&gt;I am very new to java. Any help please?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2012 22:53:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46638#M618</guid>
      <dc:creator>disha</dc:creator>
      <dc:date>2012-11-27T22:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: splunk java sdk connection to splunk failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46639#M619</link>
      <description>&lt;P&gt;Please post the source of SplunkTest.java so we can help diagnose the issue.&lt;/P&gt;

&lt;P&gt;Furthermore , ensure that your connection credentials are correct,  notably that you are using &lt;STRONG&gt;HTTPS&lt;/STRONG&gt; over Port &lt;STRONG&gt;8089&lt;/STRONG&gt; to your SplunkD Server. &lt;/P&gt;

&lt;P&gt;As a guess, you might be trying to connect to SplunkWeb on port 8000, which is not where the REST endpoints are located.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2012 23:21:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46639#M619</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2012-11-27T23:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: splunk java sdk connection to splunk failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46640#M620</link>
      <description>&lt;P&gt;Thankyou for the quick reply.Yes it was port number. I was trying to connect 8000. BUT there is one important mistake was there.:) HTTP server was not running on my machine.Now I have installed Apache http server and code is working fine. Thankyou..!!!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2012 23:47:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46640#M620</guid>
      <dc:creator>disha</dc:creator>
      <dc:date>2012-11-27T23:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: splunk java sdk connection to splunk failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46641#M621</link>
      <description>&lt;P&gt;Why are you installing an Apache HTTP Server ??&lt;BR /&gt;
You should install Splunk , and the REST client(Java SDK) will communicate to Splunk on port 8089 over HTTPS.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2012 00:01:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46641#M621</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2012-11-28T00:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: splunk java sdk connection to splunk failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46642#M622</link>
      <description>&lt;P&gt;I got it. Thanks but now I am not able to connect to remote machine. In SplunkTest.java I am giving this:&lt;BR /&gt;
 Args loginArgs = new Args();&lt;BR /&gt;
        loginArgs.add("username", "admin");&lt;BR /&gt;
        loginArgs.add("password", "xxxx");&lt;BR /&gt;
        loginArgs.add("host", "96.220.112.23");&lt;BR /&gt;
        loginArgs.add("port", 8089);&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2012 01:13:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46642#M622</guid>
      <dc:creator>disha</dc:creator>
      <dc:date>2012-11-28T01:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: splunk java sdk connection to splunk failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46643#M623</link>
      <description>&lt;P&gt;What is the error you get ?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2012 01:17:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46643#M623</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2012-11-28T01:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: splunk java sdk connection to splunk failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46644#M624</link>
      <description>&lt;P&gt;See a working example below that uses TLS v1.2 protocol with Splunk API version 1.4.0.&lt;BR /&gt;
The new Java sdk no longer implements SSL v3, instead TLS v1.2 should be used (unless you enable the SSLv3 in your Java properties: $JAVA_SDK/lib/security/java.security file and comment the line #jdk.tls.disabledAlgorithms=SSLv3).&lt;/P&gt;

&lt;P&gt;If you need to use SSL v3 you have 2 possibilities:&lt;BR /&gt;
 1. Remove the line "HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);"&lt;BR /&gt;
 2. Keep the line above and replace TLSv1_2 by SSLv3: HttpService.setSslSecurityProtocol(SSLSecurityProtocol.SSLv3;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; import java.io.*;
 import com.splunk.*;

 public class SearchExport {
     public static void main(String[] args) throws IOException {
         if(args.length != 4) {
             System.out.println("Usage:\n\tjava SplunkConnect &amp;lt;username&amp;gt; &amp;lt;password&amp;gt; &amp;lt;hostname&amp;gt; &amp;lt;port&amp;gt;");
             System.out.println("\tE.G. java SplunkConnect admin P@55w0rd 127.0.0.1 8089\n");
             System.exit(1);
         }


         /* Overriding the static method setSslSecurityProtocol to implement the security protocol of choice */
         HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);
         /* end comment for overriding the method setSslSecurityProtocol */

         ServiceArgs loginArgs = new ServiceArgs();
         loginArgs.setUsername(args[0]);
         loginArgs.setPassword(args[1]);
         loginArgs.setHost(args[2]);
         loginArgs.setPort(new Integer(args[3]));

         Service svc = Service.connect(loginArgs);
         JobExportArgs exportArgs = new JobExportArgs();
         exportArgs.setSearchMode(JobExportArgs.SearchMode.NORMAL);
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         System.out.print("Enter a search string then press &amp;lt;ENTER&amp;gt;: ");
         String mySearch = br.readLine();

         if(!(mySearch.trim().startsWith("|")) &amp;amp;&amp;amp; !(mySearch.substring(0, 6).equalsIgnoreCase("search"))) {
             mySearch = "search " + mySearch;    
         }

         InputStream exportSearch = svc.export(mySearch, exportArgs);
         MultiResultsReaderXml resultsReader = new MultiResultsReaderXml(exportSearch);

         long counter = 0;
         for(SearchResults searchResults : resultsReader) {
             for(Event event : searchResults) {
                 System.out.println("**** Event " + ++counter + " ****");
                 for(String key : event.keySet()) {
                     System.out.println("\t" + key + ": " + event.get(key));
                 }
             }
         }
         resultsReader.close();
     }
 }
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 06:45:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46644#M624</guid>
      <dc:creator>ntbahriti_splun</dc:creator>
      <dc:date>2020-09-29T06:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: splunk java sdk connection to splunk failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46645#M625</link>
      <description>&lt;P&gt;Hi  ntbahriti,&lt;BR /&gt;
I tried the above solution but I am getting the below given error. &lt;BR /&gt;
Exception in thread "main" java.lang.RuntimeException: Unrecognized SSL message, plaintext connection?&lt;/P&gt;

&lt;P&gt;Could you please help?&lt;/P&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
Y.S.Sridhar&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 20:39:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46645#M625</guid>
      <dc:creator>sreeash77</dc:creator>
      <dc:date>2017-04-04T20:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: splunk java sdk connection to splunk failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46646#M626</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Did you able to resolve this issue, even i am getting same error.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 10:24:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/splunk-java-sdk-connection-to-splunk-failed/m-p/46646#M626</guid>
      <dc:creator>chinmayc469</dc:creator>
      <dc:date>2018-08-16T10:24:23Z</dc:date>
    </item>
  </channel>
</rss>

