Error connecting Ray Cluster (Docker) using Java

Hi guys,

I’ve been trying to connect to Docker-based Ray clusters using Java, and after I specified the address in ray.conf like this: address: "ray://localhost:10001" and ran the program, an error from C code jumps up saying: gcs_client.h:49: Check failed: address.size() == 2.

I’ve already tested that this address works in python, and also tried leaving address empty (run locally), and the Java code works fine.

I tried to look into the details of the file here, and it seems that the code is trying to split address using colon ( : ) and also test if the size is 2? In which case, my address is not correct, is there a correct version of specifying the address?

Thanks!

FYI, I’m using the sample file like this:

package org.example;

import io.ray.api.ObjectRef;
import io.ray.api.Ray;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static int square(int x) {
        return x * x;
    }

    public static void main(String[] args) {
        // Initialize Ray runtime.
        Ray.init();
        List<ObjectRef<Integer>> objectRefList = new ArrayList<>();
        // Invoke the `square` method 4 times remotely as Ray tasks.
        // The tasks will run in parallel in the background.
        for (int i = 0; i < 4; i++) {
            objectRefList.add(Ray.task(Main::square, i).remote());
        }
        // Get the actual results of the tasks.
        System.out.println(Ray.get(objectRefList));  // [0, 1, 4, 9]
    }
}

Hi whatIsBest,

In python, if the address starts with ray://, it will automatically switch to client mode. But
we don’t implement the ray_client by JAVA yet, so the java worker will still understand the obtained address as a GCS address.

If you have some scenarios where you need to use ray-client in the JAVA process, we welcome you to submit an issue to the ray community.

1 Like

Thanks for the response! I understand it now, but as using GCS address seems to have issue related to ip-address matching, maybe I’ll try again about this at a later time. Thanks!

Just to understand: if I need to create Java Ray client, i.e. workers and head are Python and the client shall be Java based. Is it not feasible today? Meanwhile I got the same error with adress.lenght = 2

  • List item

I want to join the question
How with a java client do we connect to an existing running cluster?
is it possible? if so is there an example?