Laravel Echo Server is a Node.js-based server that acts as a backend for Laravel Echo, facilitating real-time event broadcasting using Socket.io. It bridges Laravel's server-side events with client-side JavaScript applications, allowing for seamless real-time features like notifications and chat. The current stable version is 1.6.3, last updated in April 2021. While not actively undergoing rapid feature development, it remains a stable and maintained solution for self-hosted real-time functionality. Key differentiators include its tight integration with the Laravel broadcasting system, providing an authentication mechanism against the Laravel application, and offering a convenient Command Line Interface (CLI) for setup and management. It supports both Redis and SQLite for persisting presence channel members and offers flexible configuration options for hosting and security (e.g., SSL, CORS).
npm install laravel-echo-serverVerified import paths — ran on the pinned version, not inferred.
Demonstrates global installation, initialization, API client setup, starting the server, and basic client-side listening using Laravel Echo.
Ensure your Laravel application is running version 6.5.2+ if you intend to use Redis prefixing. Update your `composer.json` and run `composer update`.
Set `devMode: false` in your `laravel-echo-server.json` file for production deployments. You can also control this via `LARAVEL_ECHO_SERVER_DEBUG` environment variable.
Properly configure the `apiOriginAllow` option in `laravel-echo-server.json` to include the origins of your client-side applications. Example: `"apiOriginAllow": {"allowCors": true, "allowOrigin": "*", "allowMethods": ["GET", "POST"], "allowHeaders": ["Origin", "Content-Type", "X-Auth-Token", "X-Requested-With", "Accept", "Authorization", "X-CSRF-TOKEN", "X-Socket-ID"]}`Provide the full path to your SSL certificate chain file in the `sslCertChainPath` option within `laravel-echo-server.json`.
Verify `authHost` in `laravel-echo-server.json` matches your Laravel application's URL. Ensure Laravel's `.env` file has `APP_KEY` set and `BROADCAST_DRIVER=redis` (or another appropriate driver) if using Redis for broadcasting.
Install the package globally using `npm install -g laravel-echo-server` or `yarn global add laravel-echo-server`.
Ensure your Redis server is running and accessible from the machine hosting `laravel-echo-server`. Verify the `host`, `port`, and `password` settings in your `laravel-echo-server.json`.
Check your `laravel-echo-server.json` for correct `authHost` and `apiOriginAllow` settings. Ensure you have an API client generated with `laravel-echo-server client:add APP_ID` and that `APP_ID` and `auth_key` are correctly passed in your client-side Echo configuration if using API authentication.
Verify that your Laravel application is running, the `authEndpoint` (default `/broadcasting/auth`) is correct, and your Laravel broadcasting routes are properly configured and accessible to the Echo server. Check Laravel logs for authentication errors.