Appearance
Real-time (WebSockets)
Live prices, order books, trades, balances and P2P chat reach the browser over a WebSocket. The platform sends each update to Soketi, a self-hosted server that speaks the Pusher protocol, and Soketi passes it to every open page.
How it fits together
- Something changes: a trade, a new order, a deposit.
- The platform puts a broadcast event on a queue (
market,orderbookorevents). - A Horizon worker sends it to Soketi using
PUSHER_APP_ID,PUSHER_APP_KEYandPUSHER_APP_SECRET. - Soketi pushes it to browsers connected at
wss://socket.yourdomain.com. - For private updates (your balance, your orders), the browser first proves who it is at
/api/broadcasting/auth.
So live updates need Soketi, Horizon and Redis all running.
Install and run Soketi
bash
sudo npm install -g @soketi/soketiThe PM2 process soket (soketi start --config=socket-config.json) is one of the background services in config/pm.php: the scheduler's pm:watcher starts it and keeps it running. To start it right away:
bash
cd /var/www/exchange
php artisan pm:ecosystem
pm2w start storage/app/pm2/ecosystem.json --only soket
pm2w saveAdmin → Market services shows it as WebSocket Server, with a health check on Soketi's /ready address (the port from socket-config.json). A Soketi that stops answering is restarted; one started some other way (for example the older pm2w start socket.json) is never started a second time.
socket-config.json
This file in the project root configures Soketi:
json
{
"debug": false,
"port": 6001,
"appManager.array.apps": [
{ "id": "my-app-id", "key": "my-app-key", "secret": "my-app-secret" }
]
}Replace the example credentials
The repository's socket-config.json contains sample id, key and secret values. Choose your own long random strings before going live. Anyone who knows the secret can send fake price updates to your users.
The matching .env values
The same three values go in .env, and the browser needs to know where to connect:
ini
PUSHER_APP_ID=my-app-id
PUSHER_APP_KEY=my-app-key
PUSHER_APP_SECRET=my-app-secret
PUSHER_HOST="socket.yourdomain.com"
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1
BROADCAST_DRIVER=pusher| Variable | Used by | Must match |
|---|---|---|
PUSHER_APP_ID | The platform | id in socket-config.json |
PUSHER_APP_KEY | The platform and the browser | key |
PUSHER_APP_SECRET | The platform only | secret |
PUSHER_HOST, PUSHER_PORT, PUSHER_SCHEME | Where the platform and browser connect | Your socket subdomain, 443, https |
BROADCAST_DRIVER | The platform | Must be pusher. .env.example has log, which sends nothing. |
The browser gets its copy from the MIX_PUSHER_* lines (MIX_PUSHER_APP_KEY, MIX_PUSHER_HOST, MIX_PUSHER_PORT, MIX_PUSHER_SCHEME, MIX_PUSHER_APP_CLUSTER), which repeat the values above:
ini
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_HOST="${PUSHER_HOST}"MIX_ values are built into the front-end
MIX_* values are copied into the JavaScript when you build the front-end, not when the page loads. After changing any PUSHER_* value, rebuild both bundles. Otherwise browsers keep connecting with the old values.
MIX_SOCKET_PORT in .env.example isn't used by the current front-end. You can leave it.
The socket subdomain
Browsers connect to wss://socket.yourdomain.com on port 443. Nginx passes that to Soketi on port 6001:
nginx
server {
listen 80;
server_name socket.yourdomain.com;
location / {
proxy_pass http://127.0.0.1:6001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_read_timeout 120s;
}
}You need:
- a DNS A record for
socket.yourdomain.compointing at the server - a certificate for it:
sudo certbot --nginx -d socket.yourdomain.com
Check it from your computer. A working Soketi answers with OK:
bash
curl https://socket.yourdomain.comThe connection indicator
The status bar at the bottom of the trade page shows the live connection:
| Indicator | Meaning |
|---|---|
| 🟢 Stable connection | Connected to Soketi. Prices are live. |
| 🟡 Connecting… | Connecting, or reconnecting after a short drop |
| 🔴 Connection lost | Can't reach Soketi, or the visitor's internet is down. Live prices pause and it retries automatically. |
The site footer shows Stable connection or Server Maintenance. That one follows maintenance mode, not the WebSocket.
Fixing "Connection lost"
Open the browser's developer tools (F12) → Console or Network → WS to see the error, then check:
| Cause | Fix |
|---|---|
| Soketi isn't running | pm2w status → soket online? pm2w logs soket for errors |
| DNS for the socket subdomain is missing | dig socket.yourdomain.com should show your server's IP |
| No certificate on the subdomain | The browser shows a certificate error. Run certbot for socket.yourdomain.com. |
| Nginx block missing or not reloaded | sudo nginx -t && sudo systemctl reload nginx |
| Key mismatch | PUSHER_APP_KEY, MIX_PUSHER_APP_KEY and the key in socket-config.json must be identical. Rebuild the front-end after fixing. |
| Firewall blocks 443 | Open it: sudo ufw allow 443/tcp |
| Connected, but prices never move | Horizon isn't running, or BROADCAST_DRIVER isn't pusher. Check pm2w status and .env. |
| Public data works, balances don't update | Private channel sign-in fails. Check PUSHER_APP_SECRET matches secret, and look for errors on /api/broadcasting/auth in the Network tab. |
Port 6001 only needs to be reachable from the server itself, because Nginx connects to it locally. You can block it from outside with sudo ufw deny 6001/tcp.
