Open SamF111 opened 3 years ago
In principle, yes. I guess we could add optional arguments user
and password
to Client.__init__()
, for example. But since I've never used remote client-server connections myself, may I ask: Why do you need this? When starting the server via an mph.Server
instance, we request "auto-login", i.e. we pass the command-line option -login auto
when starting comsolmphserver
so that it shouldn't require login information (if it's properly set up). Why is this not enough in your use case?
So I won't include this until someone provides a rationale for why this is useful.
As it stands, the test suite (of this library) tests local client–server connections. This works without ever providing user credentials, and it works out of the box even on a fresh Comsol installation. I like when things "just work".
There is certainly a case to be made for why this is needed for remote client–server connections. So somebody please make that case. Until then, let's not give people incentives to hard-code user credentials in their programs. Because that's how these things leak.
Hey there, First of all thanks for the amazing package. I was looking for a comsol api for python for ages, your code works great.
I might be able to weigh in here. I like to run my simulations on the server, while all the outputs and the good stuff just run locally on my laptop. I usually just forward a ssh tunnel from the mphserver running on the server and do the rest locally. This would be an application for a remote client-server connection.
Hi Killian, thanks for chiming in.
The use case is clear to me though. I'm rather wondering why the -login auto
command-line option, which I mentioned in the earlier comment and which MPh is invoking as it is, does not have the effect that you're looking for. Especially since you already have an SSH tunnel set up. As I understand it, then you're using your SSH credentials, and to the Comsol server you should look like an authenticated local user, and it should let you "log in auto"-matically, without providing a different set of user name and password.
I may misunderstand this completely though. I never had a chance to test this, and the Comsol documentation doesn't really explain what -login auto
does. So if you say this cannot be avoided and we need this in the library, then that's good enough for me.
That being said, there's already a way to do it with the current library code, it's just not documented. (Intentionally. Though I had it in mind the last time I refactored this part of the code.) If I remember correctly, you skip mph.start()
and instantiate mph.Client
directly, but pass an empty host name (host=None
or something). Then you have an "unconnected" client, on which you can call the Java method connect(host, port, user, password)
, i.e. client.java.connect(...)
in Python.
Hi, I have hardcoded together a hack, but can the other connect() options be included:
ModelUtil.connect(<host>,<port>,<user>,<password>)
as an example.