OMPython icon indicating copy to clipboard operation
OMPython copied to clipboard

Enable OMCSessionZMQ to connect to an already running omc

Open bilderbuchi opened this issue 3 years ago • 5 comments

As a user, I would like to be able to connect to an already running omc --interactive process that is listening at a certain host/port. That is, I want OMCSessionZMQ to not start a separate omc process here if I pass in an endpoint, URI, socket/port that defines where my omc is listening.

This would be useful to enable OMPython to use an omc instance that is running elsewhere, e.g. in a managed container (that I can't start myself, so the present docker support does not help here) or on a (powerful) remote server.

bilderbuchi avatar Dec 09 '21 15:12 bilderbuchi

OMC itself can be started to listen and perhaps you could connect to it. But it will only allow 1 connection and quits after the connection dies. It might not be so convenient to connect to it, but could perhaps be added as an option.

sjoelund avatar Dec 09 '21 15:12 sjoelund

Sounds good! These restrictions would be OK for our use case.

I imagine I would independently start omc --interactive --interactivePort 666 and then in Python do session = OMCSessionZMQ(port=666) (could reuse the existing port argument), session = OMCSessionZMQ(uri='localhost:666') or session = OMCSessionZMQ(uri='\\SOMEMACHINE:666') etc.

If omc can be convinced to not die after a connection dies, that could be useful, but that need is not currently on my radar. More than 1 concurrent connection I don't see as too useful, currently (I imagine that would need significant rework in omc, too).

bilderbuchi avatar Dec 09 '21 15:12 bilderbuchi

@bilderbuchi , I guess we could use the existing port argument to connect to an existing omc connection, I can add that feature

arun3688 avatar Dec 09 '21 15:12 arun3688

@arun3688 great! I think that an additional host argument (defaulting to localhost) will be useful to pair with port, then one can easily assemble a proper connection string.

bilderbuchi avatar Dec 10 '21 10:12 bilderbuchi

I would also like this feature. I am using a Mac host with a custom docker container with OpenModelica programs installed. I am able to connect to the container with a ZMQ session, but I am not able to use OMPython because of this.

scottlittle avatar Jun 24 '24 21:06 scottlittle