This is the Node.js Socket.IO server of the UDB3 search project.
Use it in conjunction with the UDB3 AngularJS application and the UDB3 backend implementations (UDB3 Backend.
[TOC]
Ensure you have installed:
Clone the [UDB3 Socket.IO][udb3-websocket-server] git repository.
Install its dependencies with npm:
npm install
Start the Socket.IO server, which listens on port 3000:
node app.js
By default a configuration file config.json is used, when present.
For a list of configuration options, read the next section.
- redis: Options passed to the socket.io-redis adapter. For more info, read the socket.io-redis documentation. Default: empty.
We recommend to use systemd to launch and control the UDB3 Socket.IO server process.
Below is a sample systemd service unit file, named uitdatabank-websocket-server.service. Replace the WorkingDirectory value with the path to your git clone, and replace the User and Group values with the unprivileged user you want to run the server as. Put the configuration file at the right location (/etc/systemd/system)
[Unit]
Description=UiTdatabank Websocket server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
User=www-data
Group=www-data
PIDFile=/var/run/udb3-websocket-server.pid
EnvironmentFile=-/etc/default/udb3-websocket-server
WorkingDirectory=/var/www/udb3-websocket-server
ExecStart=/usr/bin/node --title uitdatabank-websocket-server app.js
Restart=on-failure
RestartSec=10s
Type=simple
[Install]
WantedBy=multi-user.target
Then make systemd reload its configuration:
sudo systemctl daemon-reload
Verify the uitdatabank-websocket-server process is running correctly:
sudo systemctl status uitdatabank-websocket-server
This should output something like this (possible among other processes):
● uitdatabank-websocket-server.service - UiTdatabank Websocket server
Loaded: loaded (/lib/systemd/system/uitdatabank-websocket-server.service; enabled; vendor preset: enabled)
Active: active (running) since do 2024-09-12 13:46:01 UTC; 1 months 12 days ago
Main PID: 4338 (uitdatabank-web)
Tasks: 11
Memory: 55.9M
CPU: 1min 59.334s
CGroup: /system.slice/uitdatabank-websocket-server.service
└─4338 uitdatabank-websocket-server
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
Install and enable the mod_rewrite, mod_proxy and mod_proxy_wstunnel Apache modules.
Configuration sample to make Apache proxy incoming requests to the Socket.IO server running on port 3000 on the same host:
ProxyRequests Off
ProxyPreserveHost Off
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
RewriteEngine On
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule /socket.io/(.*)$ ws://localhost:3000/socket.io/$1 [P]