I'm using the below mentioned code in java:
import com.splunk.*; // The entry point to the client library
public class Connection
{
public static void main(String[] args)
{
ServiceArgs loginArgs = new ServiceArgs();
loginArgs.setUsername("admin");
loginArgs.setPassword("changeme");
loginArgs.setHost("apl10865gtapp14");
loginArgs.setPort(8089);
loginArgs.setScheme("http");
HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);
Service service = Service.connect(loginArgs);
for (Application app : service.getApplications().values())
{
System.out.println(app.getName());
}}}
Below mentioned is the error which I get....
Exception in thread "main" java.lang.RuntimeException: Connection refused: 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 Connection.main(Connection.java:13)
Caused by: java.net.ConnectException: Connection 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 java.net.Socket.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.http.HttpClient.
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.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.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
at com.splunk.HttpService.send(HttpService.java:403)
... 6 more
Not sure what the problem is..!!
Can you guys please help me out on this?
"Caused by: java.net.ConnectException: Connection refused: connect"
Have you validated (using telnet, maybe) that you have network connectivity between your source host and your target host apl10865gtapp14?
You probably don't have Firewall Permissions from were you run your code to your splunk instance on port 8089?
Whilst I wont be any help with solving any Java issues, (I'm not a java dev) the management port on 8089 is https, but it looks like you are using an http scheme to connect.
Try using https: loginArgs.setScheme("https");
@nickhillscpl
I have changed it to https. Still the same..:(
@Damien Dallimore
Could you please help?
Because of : Caused by: java.net.ConnectException: Connection refused: connect
I am guessing firewall.