Python VTK server + Remote View with VTK.js + multiple users

Hi,

I currently have a setup where I have a python web server using a vtk wheel and wslink to create a server and I have an javascript client connecting to it and I can load my models on the server and see them successfully on the client.

However, I want to create a multi-user setup where each user logs in to his account and creates a new session.

I am wondering if I should create my own custom code to achieve this or if you guys have this functionality built in.

I have seen this page:

Is this the approach I should be exploring? Or is there another way of achieving the same result?
Is there any more documentation or examples on this topic?

Thank you.

wslink provide the python launcher module which allow you to start a new process per user session. At that point you only need to configure it and the same is true with Apache.

So in short, you have all the pieces, but you need to configure them so they can work together and that documentation explain the role of each and what you should do to configure them.

Thank you Sebastien, I managed to get a working version. However I have a couple of questions:

Is there an example using nginx?

Also I think there’s a problem with wslink version 1.1.0 in the client, if I use version 0.1.15 in the client it works but if I use 1.1.0 on the client this error pops:

Error event: ConnectionReady TypeError: t.protocol.subscribeToImageStream(...).then is not a function
    at Object.e.connect (index.js:54)
    at Object.<anonymous> (index.js:134)
    at index.js:105
    at Array.forEach (<anonymous>)
    at l (index.js:102)

One more thing, if I close the browser tab, the process keeps going on the server, is this a mistake on my end or what can I do to close the session (plus the python process running on the server) once a user closes his tab?

Thank you very much.

I don’t have an example with nginx on hand.

There is indeed a breaking change in wslink 1.1 vs 0.1 but using vtk 9.1 with latest vtk.js should be just fine.

When you close your tab the process should go away after a timeout. I think the default is 300 seconds. But you can make it shorter if you provide the argument --timeout 10 for example.

Hi @Sebastien_Jourdain, I have tried using the “–launcher” argument while running trame application with multi user support. However, a new session window is opened even on refreshing the browser page. I have added “–timeout 30” to close older sessions But, I’m having doubt if the new session window should open on page refresh.

1 Like

Yes, that is the expected behavior unless you make it so that a page reload should reconnect to the same running session.

In general the --launcher is not meant to be use outside of a test-out environment as many port get used.

Thanks @Sebastien_Jourdain. For deployment I found this link where you have mentioned about docker. Will try it out.

Hi @Sebastien_Jourdain,
I tried the command lines below:

$ cd VTK/build
$ ./bin/vtkpython Wrapping/Python/vtk/web/launcher.py launcher.config

But I can’t find the path to launcher.py file. Do you have any slolution?

python -m wslink.launcher launcher.config

2 Likes

Hi @Sebastien_Jourdain
How can I call the api with delete methods to the launcher if I want to delete the session?

export WSLINK_LAUNCHER_DELETE=1

Remember that the session will auto-clean itself when the client disconnects after the provided --timeout. (The default timeout is 300 seconds)

When users are inactive for a period of time (for example, they freeze their computer). I want to clear the session and stop the process to free up resources

You can build up that logic within the app and do some auto shutdown if no state change happened for a given period of time.

1 Like

Hi @Sebastien_Jourdain
when the client side has connected the websocket to the server. I call the api to the launcher to delete the current session but the current server process is not stopped, and I check in the proxy-mapping file and see that the session has been deleted.
Can you give me some ideas?

Assuming you are talking about the DELETE http endpoint of the launcher, this should be triggered. Make sure it runs, and maybe try fixing that method if possible.

When I call api to launcher to delete session and stop process but can’t stop process on windows machine

So you are saying that when the launcher is running on Windows, the “kill” step does not work? Otherwise it works as expected?

That’s right. the “kill” step does not work on windows machines

Since I don’t have a Windows machine, contributions are welcome. :wink: