Getting Data In

Unable to Connect to Linux Splunk Indexer from Windows using SDK Java

Subhra
Explorer

Hi Experts,

I am new to Splunk so please bear with me if this is stupid.

I have been doing some tinkering with the Splunk SDK for Java. While I have been successfully able to connect and retrieve data to locally installed Splunk Enterprise in my Windows machine. When I try to do the same for my remote Indexer(Linux box) from my Windows machine, the program fails to connect. The code snippet is as below :

            HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1);
    ServiceArgs connectionArgs = new ServiceArgs();
    connectionArgs.setHost("hostname.domainname");
    connectionArgs.setUsername("admin");
    connectionArgs.setPassword("password");
    connectionArgs.setPort(8089);
    connectionArgs.setScheme("https");

When I run the above code from Eclipse in Windows, I get the below error :

java.lang.RuntimeException: Connection timed out: connect
at com.splunk.HttpService.send(HttpService.java:409)
at com.splunk.Service.send(Service.java:1293)
at com.splunk.HttpService.post(HttpService.java:308)
at com.splunk.Service.login(Service.java:1122)
at com.splunk.Service.login(Service.java:1101)
at com.splunk.Service.connect(Service.java:187)
at com.splunk.examples.spurl.Program.run(Program.java:40)
at com.splunk.examples.spurl.Program.main(Program.java:30)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)

Please let me know if this can be fixed, or this is the wrong way to do it. 😞

I have tried with SSLv3,TLSv1.1,TLSv1.2 but nothing works...

Tags (4)

gblock_splunk
Splunk Employee
Splunk Employee

Have you tried using curl to see if you can successfully hit the endpoint? Is the indexer behind a proxy? Is the REST API enabled?

This page has some things to try: http://dev.splunk.com/view/csharp-sdk-pcl/SP-CAAAE7W

Subhra
Explorer

Thanks for the information.

Actually yes the Indexer is behind a proxy. Also the REST API is enabled.

0 Karma

gblock_splunk
Splunk Employee
Splunk Employee

OK, I would try curl to see if you can successfully make a request and access the API.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Defend at Machine Speed: Your Guide to Security Sessions at .conf26

Splunk .conf26   With threats moving at machine speed and attack surfaces expanding across hybrid ...

Where Innovation Takes Flight: The Splunk4Aviation Flight Sim Lands at .conf26

If you hear someone at .conf26 shouting "gear down, GEAR DOWN" across the show floor, you have found us.  The ...

Turn Cisco Telemetry Into Action with Cisco Data Fabric, powered by the Splunk ...

The surge in machine data is already hitting enterprise budgets, and the agentic era will only intensify it. ...