lmenezes / cerebro-docker

official cerebro docker image
119 stars 41 forks source link

[error] p.a.h.DefaultHttpErrorHandler -- Internal server error, for (POST) [/connect] #7

Closed GuillaumeCyber closed 4 years ago

GuillaumeCyber commented 4 years ago

Hi,

I contact you because, after several attempts, I got an error when trying to access elasticsearch from cerebro web interface

############# Here are some info on my config:

 OS: Linux Mint 19.3 Tricia x86_64
 Kernel: 5.3.0-61-generic
 Docker version 19.03.12, build 48a66213fe
 docker-compose version 1.26.0, build d4451659
 Elasticsearch: version 7.8.0

#############

For information, Elasticsearch is running in a dedicated container on the same machine in "single-mode" and by doing: curl -X GET "localhost:9200/_cat/nodes?v&pretty" we get:

image

So basically the problem I'm facing appears when I'm filling in the "Node Adress" field with http://localhost:9200. Each time I got the following error message in the console:

image

If I fill in the "Node address" with "http://localhost:9200" and I check on docker logs , I got the following message:

[error] p.a.h.DefaultHttpErrorHandler - 

! @7gaa1lpli - Internal server error, for (POST) [/connect] ->

play.api.UnexpectedException: Unexpected exception[ConnectException: Connection refused: localhost/127.0.0.1:9200]
    at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:331)
    at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:253)
    at play.core.server.AkkaHttpServer$$anonfun$2.applyOrElse(AkkaHttpServer.scala:424)
    at play.core.server.AkkaHttpServer$$anonfun$2.applyOrElse(AkkaHttpServer.scala:420)
    at scala.concurrent.Future.$anonfun$recoverWith$1(Future.scala:417)
Caused by: java.net.ConnectException: Connection refused: localhost/127.0.0.1:9200
    at play.shaded.ahc.org.asynchttpclient.netty.channel.NettyConnectListener.onFailure(NettyConnectListener.java:179)
    at play.shaded.ahc.org.asynchttpclient.netty.channel.NettyChannelConnector$1.onFailure(NettyChannelConnector.java:108)
    at play.shaded.ahc.org.asynchttpclient.netty.SimpleChannelFutureListener.operationComplete(SimpleChannelFutureListener.java:28)
    at play.shaded.ahc.org.asynchttpclient.netty.SimpleChannelFutureListener.operationComplete(SimpleChannelFutureListener.java:20)
    at play.shaded.ahc.io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:577)
Caused by: play.shaded.ahc.io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/127.0.0.1:9200
Caused by: java.net.ConnectException: Connection refused
    at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
    at play.shaded.ahc.io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:327)
    at play.shaded.ahc.io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334)
    at play.shaded.ahc.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:688)

If I fill in the "Node address" with "localhost:9200", cerebro raises an unexpected exception for a bad address:

[error] p.a.h.DefaultHttpErrorHandler - 

! @7gaa4aak5 - Internal server error, for (POST) [/connect] ->

play.api.UnexpectedException: Unexpected exception[IllegalArgumentException: Invalid URL localhost:9200/_cluster/health]
    at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:331)
    at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:253)
    at play.core.server.AkkaHttpServer$$anonfun$2.applyOrElse(AkkaHttpServer.scala:424)
    at play.core.server.AkkaHttpServer$$anonfun$2.applyOrElse(AkkaHttpServer.scala:420)
    at scala.concurrent.Future.$anonfun$recoverWith$1(Future.scala:417)
Caused by: java.lang.IllegalArgumentException: Invalid URL localhost:9200/_cluster/health
    at play.api.libs.ws.ahc.StandaloneAhcWSClient.validate(StandaloneAhcWSClient.scala:100)
    at play.api.libs.ws.ahc.StandaloneAhcWSClient.url(StandaloneAhcWSClient.scala:56)
    at play.api.libs.ws.ahc.AhcWSClient.url(AhcWSClient.scala:38)
    at elastic.HTTPElasticClient.execute(HTTPElasticClient.scala:328)
    at elastic.HTTPElasticClient.executeRequest(HTTPElasticClient.scala:314)
Caused by: java.lang.IllegalArgumentException: localhost:9200/_cluster/health could not be parsed into a proper Uri, missing host
    at play.shaded.ahc.org.asynchttpclient.uri.Uri.create(Uri.java:73)
    at play.shaded.ahc.org.asynchttpclient.uri.Uri.create(Uri.java:62)
    at play.api.libs.ws.ahc.StandaloneAhcWSClient.validate(StandaloneAhcWSClient.scala:97)
    at play.api.libs.ws.ahc.StandaloneAhcWSClient.url(StandaloneAhcWSClient.scala:56)
    at play.api.libs.ws.ahc.AhcWSClient.url(AhcWSClient.scala:38)

For information I build my elastic stack from a docker-compose.yml file where I put the following information for Cerebro:

image

In the project directory I have a cerebro folder which contains: your Dockerfile and a config folder which contains application.conf file. To debug I removed all authentication mechanism and so my application.conf file looks like:

image

If you need more details, feel to ask me. Thanks in advance,

GuillaumeCyber commented 4 years ago

Actually I just realized that I can log in by using:

http://elasticsearch:9200
http://172.21.0.3:9200

So I'm wondering why it's not working with:

http://localhost:9200
http://127.0.0.1:9200

And why it raises an exception (error message) instead of a classic log message for a bad "Node address"? Thanks,

moliware commented 4 years ago

If cerebro and elasticsearch are running as docker containers, each of them are assigned an ip. So, for cerebro localhost refers to its local. To mitigate this in local development you can use host driver instead of bridge see here ( I think host driver doesn't work if you are a mac user though)