These instructions are gathered from the different documents available on Paraview and Visualizer websites.
The following instructions are for Apache on Ubuntu, similar setup could be done with other servers.
- Install Apache packages
sudo apt-get install apache2-dev apache2 libapr1-dev apache2-utils
- enable the required apache modules
sudo a2enmod vhost_alias
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_wstunnel
sudo a2enmod rewrite
-
create a new site config file (e.g.
mysite.conf
) in/etc/apache2/site-available
-
configure it with your custom path (where you see
/path/to/
), here is an example:
<VirtualHost *:80>
ServerName localhost
ServerAdmin admin@mycompany.com
DocumentRoot /path/to/data
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
<Directory "/path/to/data">
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
AllowOverride None
Require all granted
</Directory>
# Handle launcher forwarding
# port and endpoint should match launcher.config
ProxyPass /paraview http://localhost:8080/paraview
# Handle WebSocket forwarding
RewriteEngine On
# This is the path the mapping file Jetty creates
# path to proxy should match launcher.config
RewriteMap session-to-port txt:/path/to/proxy.txt
# This is the rewrite condition. Look for anything with a sessionId= in the query part of the URL and capture the value to use below.
RewriteCond %{QUERY_STRING} ^sessionId=(.*)&path=(.*)$ [NC]
# This does the rewrite using the mapping file and the sessionId
RewriteRule ^/proxy.*$ ws://${session-to-port:%1}/%2 [P]
</VirtualHost>
- make a symlink in
site-enabled
cd /etc/apache2/site-enabled
ln -s ../site-available/mysite.conf mysite.conf
- enable the virtual host and restart Apache
sudo a2ensite mysite.conf
sudo service apache2 restart
# Check the Apache log just to make sure
# If you get issue with Apache not properly listening,
# disable the default host
sudo a2dissite 000-default.conf
In a nutshell, the server will receive requests from the client and act on it.
In case of our launcher, we get a POST
request that will trigger a new instance
of Visualizer to be launched. To get the full detail on how the API works,
visit ParaViewWeb documentation.
-
Download the Paraview binaries and extract them under your path of choice.
-
create a new file
launcher.config
, same as before, replace occurences of/path/to/
with your custom path. In our case, the client will be sending an extra keydata
which will point to the filename of a data file to be loaded by default. This extra key is treated on the launcher side by the keyword${data}
:
{
"configuration": {
"host" : "localhost",
"port" : 8080,
"endpoint": "paraview",
"content": "/path/to/static/www",
"proxy_file" : "/path/to/proxy.txt",
"sessionURL" : "ws://${host}:${port}/ws",
"timeout" : 300,
"log_dir" : "/path/to/logs",
"upload_dir" : "/optional/path/to/upload/dir",
"fields" : ["file", "host", "port", "updir"]
},
"resources" : [ { "host" : "localhost", "port_range" : [9001, 9003] } ],
"properties" : {
"python_exec" : "/path/to/paraview/home/bin/pvpython",
},
"apps": {
"visualizer": {
"cmd": [
"${python_exec}", "-dr", "/path/to/visualizer/server/pvw-visualizer.py",
"--port", "${port}", "-f", "--authKey", "${secret}",
"--data", "/path/to/data", "--load-file", "${data}"
],
"ready_line" : "Starting factory"
}
}
}
Note: JSON file do not accept comments line, remove them if you added any first.
It is important that the port
, host
and /path/to/proxy.txt
match between the server config and the launcher.
Feel free to add extra-options, make sure they are sent by the web client from
dist/index.html
when connecting to the server:
// grab the parameter from the URL
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
Visualizer.connect({
application: 'visualizer',
data: getUrlParameter('data') + '.vti',
extra_param_1: 'extra_value_1',
[...]
});
- Finally start the server
export PV_HOME=/path/to/paraview
$PV_HOME/bin/pvpython $PV_HOME/lib/python2.7/site-packages/vtk/web/launcher.py /path/to/launcher.config
- Navigate with your web browser to host:port, it should start a new instance of Visualizer. To load data at startup, simply pass it as parameter in your query, e.g.:
http://localhost:8080/?data=my_data
Hi Claude,
I tried using the filename hard coded in the config json as well as the index.html. But I am not able to view the file in the Visualizer.
It is only showing the blank window/pane with no figure. I can move the orientation axes, but nothing is being rendered. Even when I choose a file from the Files tab, nothing is being displayed.
Please refer to this screenshot:
My launcher config has:
(You can see that the file name is hard coded)
The
launcher.bat
script has:However, when I launch the pvpython script directly using:
I am able to view the file. Please see this screenshot:
So, I am guessing I may have mixed up some configuration items because of which the display is not coming in the first case. Surprisingly, there are no error messages in the log files. Could you please suggest something.