webhookQuick 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-client

  • Your 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.cloud", {
  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

  1. Always use WSS — Never use unencrypted ws:// in production

  2. Use short-lived tokens — Access tokens expire every 30 minutes. Implement automatic token refresh before expiration and re-emit join after reconnecting

  3. Secure token storage — Use environment variables; never hardcode tokens in client-side code or expose them in URLs

Token Refresh Before Expiration

Connection Health Monitoring


Last updated

Was this helpful?