Quick Start & Best Practices
Get connected to the RMS-Socket service quickly and learn recommended practices for production environments.
This page covers:
A minimal connection example to get started immediately
Step-by-step connection lifecycle
Production-ready best practices for reliability and security
All examples use JavaScript (Node.js) with the socket.io-client library. For Python and browser examples, see the Code Examples page.
Quick Start
Prerequisites
Node.js installed
Socket.IO client:
npm install socket.io-clientYour Customer ID (provided by LSports)
A valid access token — see the Authentication Guide
Minimal Connection Example
const io = require("socket.io-client");
const socket = io("wss://rms.lsports.eu", {
path: "/rms-socket/socket.io",
transports: ["websocket", "polling"],
extraHeaders: {
Authorization: "Bearer YOUR_ACCESS_TOKEN",
customerid: "YOUR_CUSTOMER_ID",
},
});
socket.on("connect", () => {
console.log("Connected!");
socket.emit("join", {}, (response) => {
console.log("Joined room:", response.room);
});
});
socket.on("RESERVE_BET_ACCEPT", (data) => {
console.log("Bet accepted:", data);
});
socket.on("connect_error", (error) => {
console.error("Connection failed:", error.message);
});Connection Lifecycle
1. Connect
Establish a WSS connection with your authentication headers. Upon successful connection, the server sends an announcements event:
2. Join Room
After connecting, emit the join event to enter your designated room:
3. Receive Messages
Listen for events on your subscribed room:
4. Handle Disconnection
Handle graceful disconnection and reconnection:
Best Practices
Security
Always use WSS — Never use unencrypted
ws://in productionUse short-lived tokens — Access tokens expire every 30 minutes. Implement automatic token refresh before expiration and re-emit
joinafter reconnectingSecure token storage — Use environment variables; never hardcode tokens in client-side code or expose them in URLs
Recommended Configuration
Token Refresh Before Expiration
Connection Health Monitoring
Related
Code Examples — Full examples in JavaScript, Python, and Browser
Error Handling — Error codes and troubleshooting
Authentication Guide — Obtaining access tokens
Last updated
Was this helpful?