Splunk Search

I'm unable to connect to splunk using java application.

spideyweb008
New Member
  1. I'm accessing splunk via a VPN. So if I'm trying to access splunk via browser, after logging in using username and password, I have to provide a VIP access code as well to complete the authentication process.

  2. In java, I've tried to execute the below two codes and for each code the corresponding exception that I got is also shared below.

Starting of my java file :

public class SplunkTestService {

public void getConnectionAndTest() {

    HttpService.setSslSecurityProtocol( SSLSecurityProtocol.TLSv1_2 );

// HttpService.setSslSecurityProtocol( SSLSecurityProtocol.SSLv3 );

    ServiceArgs serviceArgs = new ServiceArgs();
            ..........................

Code :1 :

ServiceArgs serviceArgs = new ServiceArgs();
serviceArgs.setHost("https://127.0.0.1");
serviceArgs.setPort(8089);
Service service = Service.connect(serviceArgs);
service.login("USERNAME","PASSWORD");

Exception : 1:

Exception in thread "main" java.lang.IllegalArgumentException: URI can't be null.
at sun.net.spi.DefaultProxySelector.select(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source)
at com.splunk.HttpService.send(HttpService.java:445)
at com.splunk.Service.send(Service.java:1295)
at com.splunk.HttpService.post(HttpService.java:348)
at com.splunk.Service.login(Service.java:1124)
at.....

Code :2 :

ServiceArgs serviceArgs = new ServiceArgs();
serviceArgs.setHost("127.0.0.1");
serviceArgs.setPort(8089);
Service service = Service.connect(serviceArgs);
service.login("USERNAME","PASSWORD");

Exception : 2 :

refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source)
at com.splunk.HttpService.send(HttpService.java:451)
at com.splunk.Service.send(Service.java:1295)
at com.splunk.HttpService.post(HttpService.java:348)
at com.splunk.Service.login(Service.java:1124)
at.....

0 Karma

p_gurav
Champion

Can you try actual IP or localhost instead like serviceArgs.setHost("https://<IP or localhost>") instead of 127.0.0.1?

0 Karma
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...