rundeck / rundeck-api-java-client

Java client for the Rundeck REST API
http://rundeck.github.com/rundeck-api-java-client
Apache License 2.0
13 stars 17 forks source link

RundeckClient.ping() doesn't work for localhost #28

Closed andham closed 9 years ago

andham commented 9 years ago

I get "Connection refused" if trying to ping Rundeck on localhost:4440. However, using the url COMPUTERNAME:4440 works.

RundeckClientBuilder builder = RundeckClient.builder().url("http://localhost:4440");
builder.version(RundeckClient.API_VERSION);
RundeckClient rundeck = builder.login("admin", "admin").build();
rundeck.ping();

results in

Exception in thread "main" java.lang.Exception: Couldn't find a live Rundeck instance
at se.folksam.test.rundeck.RundeckMain.main(RundeckMain.java:34)
Caused by: org.rundeck.api.RundeckApiException: Failed to ping Rundeck instance at http://localhost:4440
at org.rundeck.api.ApiCall.ping(ApiCall.java:101)
at org.rundeck.api.RundeckClient.ping(RundeckClient.java:284)
at se.folksam.test.rundeck.RundeckMain.main(RundeckMain.java:30)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:4440 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:142)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:319)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:363)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:219)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at org.rundeck.api.ApiCall.ping(ApiCall.java:95)
... 2 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:72)
at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:125)
... 13 more
gschueler commented 9 years ago

i am able to ping localhost as well as hostname. is the rundeck server not listening on the localhost interface? are you able to curl the localhost url?

andham commented 9 years ago

Yes, I can curl the localhost url and get a 302 answer.

I see something else probably related to this: Using a browser, if I go to http://localhost:4440 (end up in http://localhost:4440/user/login) and try to log in I'm just returned to http://COMPUTERNAME:4440/user/login. If I then try to log in it will succeed. (Browser: Firefox 37.0.1)

Environment: Windows 7, Oracle JDK 1.7.0_72, Rundeck 2.5.0

gschueler commented 9 years ago

the value for grails.serverURL in rundeck-config.properties is used as the base URL for grails, and is used in redirects. Forgot this might be the issue earlier. basically, you should access rundeck using that URL.

andham commented 9 years ago

Right, it was that simple! My bad then!