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

**URL:** https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060
**Category:** Web
**Created:** [November 3, 2021, 5:21pm UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060 "2021-11-03T17:21:55Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![joaomlap](https://discourse.vtk.org/user_avatar/discourse.vtk.org/joaomlap/32/3201_2.png) [@joaomlap](https://discourse.vtk.org/u/joaomlap)
#### Post date: [November 3, 2021, 5:21pm UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/1 "2021-11-03T17:21:55Z")

</div>

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:

> **[ParaViewWeb](https://kitware.github.io/paraviewweb/docs/multi_user_setup.html)**
>
> Multi-user Setup GuideIntroductionThis document describes the three components required to deploy ParaViewWeb in a multi-user environment. These three components are depicted in the following image,

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.

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [November 3, 2021, 7:03pm UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/2 "2021-11-03T19:03:02Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![joaomlap](https://discourse.vtk.org/user_avatar/discourse.vtk.org/joaomlap/32/3201_2.png) [@joaomlap](https://discourse.vtk.org/u/joaomlap)
#### Post date: [November 16, 2021, 4:44pm UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/3 "2021-11-16T16:44:09Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [November 17, 2021, 10:28pm UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/4 "2021-11-17T22:28:41Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![simplyvish](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/e47774/32.png) [@simplyvish](https://discourse.vtk.org/u/simplyvish)
#### Post date: [April 11, 2022, 8:55am UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/5 "2022-04-11T08:55:04Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [April 11, 2022, 2:50pm UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/6 "2022-04-11T14:50:19Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![simplyvish](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/e47774/32.png) [@simplyvish](https://discourse.vtk.org/u/simplyvish)
#### Post date: [April 12, 2022, 6:02am UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/7 "2022-04-12T06:02:11Z")

</div>

Thanks @Sebastien_Jourdain. For deployment I found [this](https://discourse.vtk.org/t/advises-for-installing-vtk-web-application/8096/2) link where you have mentioned about docker. Will try it out.

---

<div class="post-metadata">

### Author: ![dbtruong](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@dbtruong](https://discourse.vtk.org/u/dbtruong)
#### Post date: [June 13, 2023, 1:56am UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/8 "2023-06-13T01:56:03Z")

</div>

Hi @Sebastien_Jourdain,  
I tried the command lines below:

```auto
$ 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?

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [June 13, 2023, 3:32pm UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/9 "2023-06-13T15:32:09Z")

</div>

`python -m wslink.launcher launcher.config`

---

<div class="post-metadata">

### Author: ![dbtruong](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@dbtruong](https://discourse.vtk.org/u/dbtruong)
#### Post date: [August 30, 2023, 7:12am UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/10 "2023-08-30T07:12:32Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [August 30, 2023, 2:30pm UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/11 "2023-08-30T14:30:47Z")

</div>

`export WSLINK_LAUNCHER_DELETE=1`

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [August 30, 2023, 2:32pm UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/12 "2023-08-30T14:32:26Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dbtruong](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@dbtruong](https://discourse.vtk.org/u/dbtruong)
#### Post date: [August 30, 2023, 10:43pm UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/13 "2023-08-30T22:43:26Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [August 30, 2023, 11:20pm UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/14 "2023-08-30T23:20:27Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![dbtruong](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@dbtruong](https://discourse.vtk.org/u/dbtruong)
#### Post date: [September 13, 2023, 2:54pm UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/15 "2023-09-13T14:54:24Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [September 13, 2023, 7:35pm UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/16 "2023-09-13T19:35:59Z")

</div>

Assuming you are talking about the DELETE http endpoint of the launcher, [this](https://github.com/Kitware/wslink/blob/master/python/src/wslink/launcher.py#L450-L456) should be triggered. Make sure it runs, and maybe try fixing that method if possible.

---

<div class="post-metadata">

### Author: ![dbtruong](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@dbtruong](https://discourse.vtk.org/u/dbtruong)
#### Post date: [September 15, 2023, 10:08am UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/17 "2023-09-15T10:08:29Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [September 15, 2023, 8:46pm UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/18 "2023-09-15T20:46:56Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dbtruong](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@dbtruong](https://discourse.vtk.org/u/dbtruong)
#### Post date: [September 16, 2023, 3:03am UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/19 "2023-09-16T03:03:33Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [September 16, 2023, 2:53pm UTC](https://discourse.vtk.org/t/python-vtk-server-remote-view-with-vtk-js-multiple-users/7060/20 "2023-09-16T14:53:23Z")

</div>

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