Using compas_RPC on remote server

Hi there!

Thanks for the work on compas so far! Is there some experience at BRG to run the RPC remotely? Or to work in a remote anaconda environment. Such a solution would allow us to use compas/python in GH without the need to set up a local environment for every employer at the office wanting to just open/run a script or make minor adjustments.

I ask because of the note at tutorial/rpc page:

Currently, the RPC server is launched on the localhost . However, it would also be possible to launch it on a remote computer on a network, or on a server reachable over the internet.

Have a nice day,
Lennert

Hi @ney-llo

Yes, this should work. The RPC server already binds to 0.0.0.0 (which means it listens to all network interfaces), so, if the machine on which you set this up is reachable over the network, the service would be available. Then you’d need to start the proxy with the URL of your compas server, eg.:

from compas.rpc import Proxy

with Proxy('compas.numerical', url='http://compas.ney.partners') as numerical:
    # here do something with remote RPC

IMPORTANT: Please notice that this basically allows remote code execution on your server, so, you should secure it properly. This mean, do not put it open on the internet (either make it available only through your internal network and/or over your private vpn, or add an extra layer of authentication on top), ideally, sandbox the execution environment as well. As an (admittedly trivial) way to sandbox it, I would suggest to at least run the RPC server in Docker containers. I’ve put together a minimal example to build a docker container that starts an RPC server ready to serve external requests, check it out here, it should be as simple as “compose up” on this one and it should work.

Cheers

1 Like

Thanks Gonzalo. I will have a look at it.

1 Like