Problem connecting on a local h20 java session when having job array

Dear all

I am trying to use H20 within R to analyze some data.
H20 has some highly efficient trained AI models, that I would like to use. In R, there is the h20 R package, which gives convenient functions to connect to an h20 server. If there is no server to connect to with an h20 instance running, it launches a local instance of a java serve with h20 and connect to it, see https://docs.h2o.ai/h2o/latest-stable/h2o-r/docs/articles/h2o-r-package.html.

It does work well on baobab: R launch a local java instance of h20 on IP “127.0.0.1” port 54321 and connect to it. But I would like to launch job array of 20 instances, and if I launch a job array, it no longer works, and I obtain the following error:

Error in .h2o.doSafeREST(h2oRestApiVersion = h2oRestApiVersion, urlSuffix = urlSuffix, :
Unexpected CURL error: Failed to connect to localhost port 54321: Connection refused
Calls: as.h2o … h2o.uploadFile → .h2o.doSafePOST → .h2o.doSafeREST
Execution halted

What could I do? My tests are the h20_baobab_testing.R and the associated baobab_h20_test.sh files, in the trip_advisor folder.

Thank you for the help

Denis

Hi, you should use a distinct port per java instance. As stated in the documentation, you need to init h20 with a parameter to do so.

2o.init without any arguments, and H2O will be automatically launched at localhost:54321, where the IP is “127.0.0.1” and the port is 54321. If H2O is running on a cluster, you must provide the IP and port of the remote machine as arguments to the h2o.init() call.

1 Like

Hy Yann

Sorry I come back to this question months after (just have the time to retry that now).
What are the ports that are allowed to connect to ? I changed the port according to the baobab job, and some managed to connect, others no.

Hi, @Denis.Mongin

all the ports bigger than 1024 could be usable. The issue you may face is if the port is already in use this will fail. You should check if a port is free and use it.

Example script (quick and dirty, to be adapted to your use case:

#!/bin/sh
## check if the port in argument is free to use or already listening

PORT=$1
if $(ss -tln '( dport = :'${PORT}' or sport = :'${PORT}' )' | grep LISTEN -q)
then
   echo "port $PORT already in use"
   exit 1
else
   echo "port $PORT free"
fi

Example

(baobab)-[sagon@cpu001 ~]$ ./bla.sh 22
port 22 already in use
(baobab)-[sagon@cpu001 ~]$ ./bla.sh 23
port 23 free