How do I connect TLS-enabled head node in Python script?

How severe does this issue affect your experience of using Ray?

  • High: It blocks me to complete my task.

I could start TLS-enabled ray cluster the following command, and running $ RAY_USE_TLS=1 RAY_TLS_ SERVER_CERT=... -snip- ... ray start --address="10.xxx.yyy.zzz:8000" works well as connecting a new one.

RAY_USE_TLS=1 \
RAY_TLS_SERVER_CERT=<path-to-cert> \
RAY_TLS_SERVER_KEY=<path-to-key> \
RAY_TLS_CA_CERT=<path-to-cert> \
ray start --head --node-ip-address="10.xxx.yyy.zzz" --port="8000" --include-dashboard=False --disable-usage-stats

However, I can’t connect in my Python script. In some issue about connecting TLS-enabled head-node, they use the following snippet. I tried but didn’t go well.

import os
import ray

os.environ["RAY_USE_TLS"] = "1"
os.environ["RAY_TLS_SERVER_CERT"] = "<path-to-cert>"
os.environ["RAY_TLS_SERVER_KEY"] = "<path-to-key>"
os.environ["RAY_TLS_CA_CERT"] = "<path-to-ca-cert>"
RAY_HOST = "10.xxx.yyy.zzz" 

ray.init()

ref:

Does it really work?

Hi @Krout0n ! What Ray version do you experience this on?

Hi @cade ! I noticed I’m using secretflow-ray which is provided by the other community… So I should ask to them… what's different between secretflow-ray and ray, where can I pull the code of secretflow-ray? · Issue #226 · secretflow/secretflow · GitHub

BTW I can run what I want with the following command. So that’s already been resolved. Thanks for your concern!

RAY_USE_TLS=1 \
RAY_TLS_SERVER_CERT=<path-to-cert> \
RAY_TLS_SERVER_KEY=<path-to-key> \
RAY_TLS_CA_CERT=<path-to-cert> \
python <my-ray-script>.py
1 Like

Great!

I wonder if you had switched the os.environ[x] = y lines with the ray import, it would have worked?

import os


os.environ["RAY_USE_TLS"] = "1"
os.environ["RAY_TLS_SERVER_CERT"] = "<path-to-cert>"
os.environ["RAY_TLS_SERVER_KEY"] = "<path-to-key>"
os.environ["RAY_TLS_CA_CERT"] = "<path-to-ca-cert>"
RAY_HOST = "10.xxx.yyy.zzz" 

import ray
ray.init()
1 Like

Yes it worked! My import-order was wrong…

1 Like