WebSocket Proxy Service
The WebSocket Proxy service enables real-time communication between the server and client applications. It handles live notifications, real-time data updates, and push events for the Tenant Frontend.
Architecture
Tenant Frontend (Browser)
│ WebSocket (wss://)
▼
WS Proxy Backend (Laravel 12)
│
├──▶ Redis (pub/sub, channel state)
├──▶ RabbitMQ (event consumption)
└──▶ PostgreSQL (channel auth)
Key Features
Real-Time Channels
- Private channels — Authenticated user-specific events
- Presence channels — Track who's online (e.g., admin dashboard)
- Public channels — Broadcast events to all connected clients
Event Types
- Order status updates (real-time tracking)
- Stock level changes (live inventory)
- New customer notifications
- System alerts and announcements
- Dashboard live data refresh
Connection Management
- WebSocket upgrade from HTTP
- Automatic reconnection handling
- Connection heartbeat and timeout
- Per-user channel authorization
How It Works
- Frontend opens WebSocket connection to WS Proxy
- User subscribes to channels (e.g.,
orders.{tenant_id}) - WS Proxy verifies authorization via Identity service
- Backend services publish events to RabbitMQ
- WS Proxy consumes events and broadcasts to subscribers
Backend Service ──▶ RabbitMQ ──▶ WS Proxy ──▶ Browser (WebSocket)
Client Integration
Frontend (Vue 3)
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';
const echo = new Echo({
broadcaster: 'pusher',
wsHost: '{tenant}.vecton.hu',
wsPort: 443,
wssPort: 443,
forceTLS: true,
disableStats: true,
enabledTransports: ['ws', 'wss'],
});
// Listen for order updates
echo.private(`orders.${tenantId}`)
.listen('OrderStatusChanged', (event) => {
console.log('Order updated:', event.order);
});
// Presence channel (who's online)
echo.join(`dashboard.${tenantId}`)
.here((users) => console.log('Online:', users))
.joining((user) => console.log('Joined:', user))
.leaving((user) => console.log('Left:', user));
Channels
| Channel Pattern | Type | Description |
|---|---|---|
orders.{tenantId} | Private | Order status updates |
stock.{tenantId} | Private | Stock level changes |
notifications.{userId} | Private | User notifications |
dashboard.{tenantId} | Presence | Admin dashboard users |
announcements | Public | System-wide broadcasts |
API Endpoints
Base URL: https://{tenant}.vecton.hu/api/ws (production) | http://localhost:8015/api (dev)
| Method | Endpoint | Description |
|---|---|---|
| GET | /broadcasting/auth | Channel authorization |
| POST | /broadcasting/auth | Authenticate private/presence channel |
| GET | /health | WebSocket server health check |
Configuration
| Variable | Description | Default |
|---|---|---|
APP_URL | Service base URL | http://localhost:8015 |
DB_SCHEMA | Database schema | ws_proxy |
BROADCAST_DRIVER | Laravel broadcast driver | pusher |
PUSHER_APP_ID | Pusher/Soketi app ID | app-id |
PUSHER_APP_KEY | Pusher/Soketi app key | app-key |
PUSHER_APP_SECRET | Pusher/Soketi secret | app-secret |
Development
cd tenant/tenant-backend-ws-proxy
composer install
php artisan migrate
php artisan serve --port=8015