Run socket server command
php socket_server start -d
Stop socket server command
php socket_server stop
Restart socket server command
php socket_server restart
Status socket server command
php socket_server info
Spoiler: CloudFlare port for Websocket
Setup for Swoole usage
Sample configs for connecting through a proxy
Spoiler: Nginx
NGINX:
location /socket.io/ {
proxy_pass http://127.0.0.1:2053;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
Spoiler: Apache
Apache config:
ProxyPass /socket.io/ http://localhost:2020/ upgrade=websocket
Spoiler: OpenLiteSpeed
Code:
extprocessor socket.io {
type proxy
address 127.0.0.1:2053
maxConns 2000
pcKeepAliveTimeout 60
initTimeout 60
retryTimeout 0
respBuffer 0
}
context /socket.io/ {
type proxy
handler socket.io
addDefaultCharset off
}
websocket /socket.io {
address 127.0.0.1:2053
}
Managing a socket server as a Systemd service
Create a file named "livecontent.service" along the path "/etc/systemd/system".
You can create it manually or execute it in the console "
systemctl edit --force --full livecontent.service
"
In the created file, we write the unit instructions.
Code:
[Unit]
Description=Live Content socket server
After=mysql.service
Requires=mysql.service
[Service]
Type=forking
PIDFile=/www/wwwroot/domen.com/src/addons/DCom/LiveContent/SocketServer/SwooleServer/swoole_server.pid
WorkingDirectory=/www/wwwroot/domen.com
ExecStart=/usr/bin/php socket_server start -d
ExecStop=/usr/bin/php socket_server stop
ExecReload=/usr/bin/php socket_server restart
TimeoutSec=300
Restart=always
[Install]
WantedBy=multi-user.target
Alias=livecontent.service
Variables in bold change to your own depending on the system
Do not forget to reload the systemd daemon after fixes in the unit
systemctl daemon-reload
We look at the status of the unit
systemctl status livecontent
We see that it is disabled - we allow it
systemctl enable livecontent
systemctl -l status livecontent
Starting the service
systemctl start livecontent
We look at the beautiful status:
systemctl -l status livecontent
Setting up the Pusher connection
You sign up for the Pusher service
Select the Channels product
In the Pusher panel, switch to the AppKeys tab
Enter these authentication details in the Xenforo admin panel and click save