Dgraph-ratel unable to connect to dgraph server on localhost


(Keelan Johns) #1

I have setup dgraph to test using docker and want to do the same natively in linux. Everything installs smoothly (zero, server, and ratel all on one server) and getting the dgraph servers to run in “screens” is working. When I open up ratel in the browser it renders properly but gives me an error: “Not connected (http://127.0.0.1:9080/)”. I check netstat with the following and see that dgraph is listening on 9080. I even run each of the dgraph servers as root (hoping it is a stupid permissions issue) and still get the same error. I feel pretty silly for not being able to connect to the dgraph server running locally. Any thoughts?


(Pawan Rawal) #2

HTTP port for Dgraph by default is 8080, so try connecting Ratel to localhost:8080. If that doesn’t work, then share logs from running Docker container please.


(Keelan Johns) #3

Pawan,

Thank you for the help. Sorry, I should have added that yes, dgraph-ratel was set to connect to the server on http://127.0.0.1:8080/ by default. I had tried port 9080 as well since it apparently is the other port dgraph server is listening on. Either way, dgraph-ratel cannot connect to localhost:8080 nor localhost:9080.

Also I am running these services directly through linux (not docker on linux) to test out this setup. I had already quickly gotten dgraph up and runnning on docker but want to see it’s performance/setup natively on linux. I do not see any reference to log files. So, what I just tried is to pass the outputs of each of the services to log files. For example: “dgraph-ratel >> /log/dgraphratel.log”. Apparently, dgraph-ratel does not post anything to the terminal though.

Running “sudo find / -name “dgraph”” also only resulted in finding the applications themselves, my logs, and some unrelated modgraph thing. Is there any other location I should look for dgraph-ratel logs?

Thanks!


(Pawan Rawal) #4

9080 is the port for gRPC server to which the clients connect to. Since Ratel connects to the server over HTTP, it connects to 8080.

The server only logs to stdout, we’ll probably start logging to a file also soon. Ratel doesn’t log anything as you have observed.


(Keelan Johns) #5

Welp, after some trial and error I’ve got it working. One other thing I did not say in my post was that I am running the dgraph servers on a development server but connecting to dgraph-ratel through the browser of my laptop. When I specify the development server’s local IP:8080 dgraph-ratel is able to connect. I swear I tried this before my original post but maybe some other changes I made were necessary as well (making a dgraph folder at “/” owned by root, then running each of the dgraph services as root from within this folder).

I did not expect dgraph-ratel to be configured from the client’s browser (and it’s ip) (and thus needing the local IP of the host dgraph server is running on (which also happens to be the host dgraph-ratel is running on)). I expected dgraph-ratel to try to connect to dgraph server from the server dgraph-ratel is running on (and thus localhost). I can see how this won’t matter when setting up an application to connect to the dgraph api (9080).

One thing I do not understand is the role of dgraph zero. Why are we connecting directly to one server node (in a one node cluster) rather than connecting to dgraph zero and letting it route our data to the appropriate dgraph server? Maybe I just need to go through the exercise of setting up multiple dgraph server nodes for it to become apparent. If there is a quick answer, feel free to let me know.

Anyway, thanks again!


(Pawan Rawal) #6

Yeah, Ratel connects directly to the server. So port for the server should also be exposed outside.

Zero doesn’t route requests to the appropriate server. Dgraph servers do that among themselves. Zero does other things like uid assignment and shard rebalancing, read more at https://docs.dgraph.io/deploy


(James) #7

hi,

i tried to add tls via caddy to proxy rest call to port 8080.
but when i use Ratel on this address
https://localhost:8080

it fails to connect.
it works well when i did not use caddy to proxy via https (tls self signed)

and also, i even tried to add login for httpbasic auth, and Ratel seems to remove authentication from the url.

example:

http://username:password@ip:8080/

becomes

http://ip:8080/

is there a way to make this work?


(Michel Conrado) #8

Hi, James.

I’ve never used Caddy. But can I try to help, can you exemplify what you did to ride Dgraph with Caddy? That way I try to reproduce here and give a solution or explanation.

I’m using Windows.


(James) #9

Hi

Yes i know dgraph uses port 8080, im not porting the port out to host machine on docker, but instead i proxied caddy To dgraph 8080 and exposes https port caddy to host machine. Port is open when open from browser, but ratel does not seems to work


(Michel Conrado) #10

Ratel is 8000. You need both ports forward.


(James) #11

yes i have ratel working, but not able to connect via those url


(Michel Conrado) #12

That’s some problem with Caddy. If you are able to use Ratel, but port 8080 is not accessible by the same URL that Caddy provides. So it’s a Caddy configuration problem.


(James) #13

Hi MichelDiz,

opening https://localhost:8080 does work on browser, except the tls is self generated, so ive to bypass it, then it shows:

Dgraph browser is available for running separately using the dgraph-ratel binary

but dratel, the inner url does not work with the same url

its not priority :slight_smile:


(Michel Conrado) #14

If you see Dgraph msg in https://localhost:8080

Dgraph browser is available for running separately using the dgraph-ratel binary

and can’t access Ratel in https://localhost:8000

So it’s a Caddy issue. This is out of Dgraph’s scope. I can try to help you, but you need to give me a path of how you’re doing this.

I see you’re trying to do something like “reverse proxy”. It’s a fact that it’s a Caddy issue. Dgraph works on separate ports under the same URL. If you want to configure the Caddy to work on the same URL and same port. You need to set up the Caddy correctly.


(James) #15

@MichelDiz

http://localhost:8000 is working.
i can see the dgraph ratel, only it cant connect to https://localhost:8080 within the connector address of ratel

something like this below, except if i use https with port 8080, it will fail.
could this because im using self signed tls on caddy?
09%20AM


(Michel Conrado) #16

I’m not aware of it, I believe that Ratel does not have any restriction with tls. You can access any URL that has Dgraph running. As far as I know Ratel is not able to verify TLS or any other type like SSL.

We will soon have a simpler configuration with TLS.