The `message-bus-client` package is the official JavaScript client library for connecting to the Ruby `message_bus` server. It provides robust functionalities for subscribing to channels, receiving real-time messages via polling, long-polling, or long-polling with streaming, and managing subscriptions and message backlogs. Designed to work seamlessly with the `message_bus` Ruby gem, which acts as a Rack middleware, it enables scalable concurrent connections. The current stable version is 4.5.2, reflecting active maintenance, as it is a critical component of Discourse, where it's used in production at scale. Its primary role is to establish a reliable client-server communication channel for web applications.
npm install message-bus-clientVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to initialize the MessageBus client, subscribe to multiple channels, and receive real-time messages. It includes optional server URL configuration.
Ensure your MessageBus server application is running on Ruby 3.2 or a newer officially supported Ruby version. Consult the Ruby gem's documentation for current support policies.
Refer to the MessageBus Ruby gem's documentation for detailed server setup instructions, especially regarding Rack Hijack and web server configurations (Puma, Unicorn, Thin, Passenger) to ensure efficient long-polling.
Review the release notes for both `message-bus-client` and the `message_bus` Ruby gem before upgrading. Aim to keep both components on closely matched or explicitly compatible major versions to avoid synchronization issues.
Configure your MessageBus server (Rack application) to include appropriate `Access-Control-Allow-Origin` headers that permit requests from your client's domain. Tools like `rack-cors` can simplify this configuration in Ruby applications.
Verify that your MessageBus server (Ruby application) is actively running and reachable from the client's network. Check server logs for startup errors and ensure the `baseUrl` configured in the client matches the server's address.
On the MessageBus server, configure CORS to allow requests from your client's domain (e.g., `http://your-client-domain.com`). This typically involves adding middleware like `rack-cors` in Ruby Rack applications.
Ensure that `MessageBus` is instantiated correctly with `new`: `const bus = new MessageBus();`.
No dependency data recorded yet.