<?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: Unable to Connect to Splunk: Connection Refused -- while using Java SDK in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Unable-to-Connect-to-Splunk-Connection-Refused-while-using-Java/m-p/46549#M614</link>
    <description>&lt;P&gt;I also get an same error "Connection Refused" when I use the hostname given at the time of Splunk Cloud signup with the port number 8089.&lt;BR /&gt;
But, if I use cURL or HTTP client app (without using Java SDK), I successfully get the session token only if I prefix "input-" to the hostname. If I don't prefix, I get the same "Connection Refused".&lt;BR /&gt;
If I use the prefixed hostname in the Java SDK code, I get an error:&lt;/P&gt;

&lt;P&gt;"hostname in certificate didn't match:  != "&lt;/P&gt;

&lt;P&gt;If I use localhost as hostname (without prefix), I get an error:&lt;/P&gt;

&lt;P&gt;"hostname in certificate didn't match:  != "&lt;/P&gt;

&lt;P&gt;All cURL REST API calls to localhost work well.&lt;BR /&gt;
It is not a port number issue, but a hostname and certificate issue.&lt;BR /&gt;
Please help us solve this issue. I would like to use Java SDK rather than working on the REST API level.&lt;BR /&gt;
There might be more setting we have to do on the Service object.&lt;/P&gt;</description>
    <pubDate>Fri, 30 Jan 2015 17:41:40 GMT</pubDate>
    <dc:creator>snaplogic15</dc:creator>
    <dc:date>2015-01-30T17:41:40Z</dc:date>
    <item>
      <title>Unable to Connect to Splunk: Connection Refused -- while using Java SDK</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Unable-to-Connect-to-Splunk-Connection-Refused-while-using-Java/m-p/46545#M610</link>
      <description>&lt;P&gt;Hi ,&lt;BR /&gt;
I am trying to connect Splunk using Java SDK but i am getting Connection Refused Exception.&lt;/P&gt;

&lt;P&gt;Map&lt;STRING&gt; connectionArgs = new HashMap&lt;STRING&gt;();&lt;BR /&gt;
         connectionArgs.put("host", "mydomain.com");&lt;BR /&gt;
         connectionArgs.put("username", "admin");&lt;BR /&gt;
         connectionArgs.put("password", "passxxx");&lt;BR /&gt;
         connectionArgs.put("port", 8089);&lt;BR /&gt;
         connectionArgs.put("scheme", "https");&lt;BR /&gt;
         Service splunkService = Service.connect(connectionArgs); &lt;/STRING&gt;&lt;/STRING&gt;&lt;/P&gt;

&lt;P&gt;When I am using the browser with the above url i, e, &lt;A href="https://mydomain.com"&gt;https://mydomain.com&lt;/A&gt; i am able to login with the above credentials but through Java sdk i am not able to connect. I debugged the code, In HttpService.java class the URL is getting constructed as &lt;BR /&gt;
&lt;A href="https://mydomain.com:8089/services/auth/login"&gt;https://mydomain.com:8089/services/auth/login&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I am not getting why the URL is getting constructed like this. Kindly help me out in resolving the issue at the earliest. Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2013 12:50:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Unable-to-Connect-to-Splunk-Connection-Refused-while-using-Java/m-p/46545#M610</guid>
      <dc:creator>madhuinfy</dc:creator>
      <dc:date>2013-05-27T12:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to Connect to Splunk: Connection Refused -- while using Java SDK</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Unable-to-Connect-to-Splunk-Connection-Refused-while-using-Java/m-p/46546#M611</link>
      <description>&lt;P&gt;This URL is constructed to hit the splunkd daemon management port (8089, by default) and then the &lt;CODE&gt;/services/auth/login&lt;/CODE&gt; endpoint to obtain a session token. See &lt;A href="http://dev.splunk.com/view/basic-tutorial/SP-CAAADQT"&gt;this dev.splunk.com tutorial&lt;/A&gt; for more details.&lt;/P&gt;

&lt;P&gt;In your case, since you are seeing a "connection refused" message, it appears that either the splunkd daemon is not running, or it has been configured to listen on a port different than 8089. If the latter is true, you'll need to specify that port when constructing the connection instance:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;// Create a map of arguments and add login parameters
ServiceArgs loginArgs = new ServiceArgs();
loginArgs.setUsername("admin");
loginArgs.setPassword("changeme");
loginArgs.setHost("localhost");
loginArgs.setPort(8089);

// Create a Service instance and log in with the argument map
Service service = Service.connect(loginArgs);
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See &lt;A href="http://dev.splunk.com/view/SP-CAAAECX"&gt;this tutorial&lt;/A&gt; for reference.&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2013 15:10:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Unable-to-Connect-to-Splunk-Connection-Refused-while-using-Java/m-p/46546#M611</guid>
      <dc:creator>hexx</dc:creator>
      <dc:date>2013-05-27T15:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to Connect to Splunk: Connection Refused -- while using Java SDK</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Unable-to-Connect-to-Splunk-Connection-Refused-while-using-Java/m-p/46547#M612</link>
      <description>&lt;P&gt;Since i was not sure about the port number,i had put a for loop from 0 to 10000 as shown below, but still getting same issue.This time instead of using domain name i used the ip address itself as below connectionArgs.put("host","165.130.166.206");&lt;BR /&gt;
connectionArgs.put("username", "admin");connectionArgs.put("password", "passxx");connectionArgs.put("scheme", "https");&lt;BR /&gt;
for(i=0;i&amp;lt;=10000;i++){try{connectionArgs.put("port",i);&lt;BR /&gt;
Service splunkService = Service.connect(connectionArgs); &lt;BR /&gt;
System.out.println("Connected");}catch(Exception e){&lt;BR /&gt;
 System.out.println("could not Connect, The Port No is " + i);}}&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2013 06:59:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Unable-to-Connect-to-Splunk-Connection-Refused-while-using-Java/m-p/46547#M612</guid>
      <dc:creator>madhuinfy</dc:creator>
      <dc:date>2013-05-28T06:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to Connect to Splunk: Connection Refused -- while using Java SDK</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Unable-to-Connect-to-Splunk-Connection-Refused-while-using-Java/m-p/46548#M613</link>
      <description>&lt;P&gt;I think you'd be better off finding out what the splunkd management port is by reading it in $SPLUNK_HOME/etc/system/local/web.conf or by issuing the "splunk show splunkd-port" command.&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2013 13:58:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Unable-to-Connect-to-Splunk-Connection-Refused-while-using-Java/m-p/46548#M613</guid>
      <dc:creator>hexx</dc:creator>
      <dc:date>2013-05-28T13:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to Connect to Splunk: Connection Refused -- while using Java SDK</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Unable-to-Connect-to-Splunk-Connection-Refused-while-using-Java/m-p/46549#M614</link>
      <description>&lt;P&gt;I also get an same error "Connection Refused" when I use the hostname given at the time of Splunk Cloud signup with the port number 8089.&lt;BR /&gt;
But, if I use cURL or HTTP client app (without using Java SDK), I successfully get the session token only if I prefix "input-" to the hostname. If I don't prefix, I get the same "Connection Refused".&lt;BR /&gt;
If I use the prefixed hostname in the Java SDK code, I get an error:&lt;/P&gt;

&lt;P&gt;"hostname in certificate didn't match:  != "&lt;/P&gt;

&lt;P&gt;If I use localhost as hostname (without prefix), I get an error:&lt;/P&gt;

&lt;P&gt;"hostname in certificate didn't match:  != "&lt;/P&gt;

&lt;P&gt;All cURL REST API calls to localhost work well.&lt;BR /&gt;
It is not a port number issue, but a hostname and certificate issue.&lt;BR /&gt;
Please help us solve this issue. I would like to use Java SDK rather than working on the REST API level.&lt;BR /&gt;
There might be more setting we have to do on the Service object.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jan 2015 17:41:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Unable-to-Connect-to-Splunk-Connection-Refused-while-using-Java/m-p/46549#M614</guid>
      <dc:creator>snaplogic15</dc:creator>
      <dc:date>2015-01-30T17:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to Connect to Splunk: Connection Refused -- while using Java SDK</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Unable-to-Connect-to-Splunk-Connection-Refused-while-using-Java/m-p/46550#M615</link>
      <description>&lt;P&gt;Check the management port number. If it is not 8089 use the same port number in you r code too.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Oct 2018 15:44:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Unable-to-Connect-to-Splunk-Connection-Refused-while-using-Java/m-p/46550#M615</guid>
      <dc:creator>chandrasekharko</dc:creator>
      <dc:date>2018-10-29T15:44:08Z</dc:date>
    </item>
  </channel>
</rss>

