Registry / http-networking / laravel-echo-server

laravel-echo-server

JSON →
library1.6.3jsnpmunverified

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-server
INSTALL
IMPORT
SIG · LARAVEL-ECHO-SERVE
L
laravel-echo-server
http-networkingjavascriptv1.6.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Server
import { Server } from 'laravel-echo-server';
const Server = require('laravel-echo-server');
For programmatic usage (e.g., embedding the server within another Node.js application), the `Server` class is the primary export. While CommonJS `require` works, ESM `import` is preferred in modern Node.js applications.
CLI Commands
laravel-echo-server init
node_modules/.bin/laravel-echo-server init
The package is primarily used via its globally installed CLI tool. Direct programmatic imports for the CLI functions are less common than simply running the commands.
Configuration options
// Refer to laravel-echo-server.json
While not a code import, the `laravel-echo-server.json` file is the central way to configure the server, including `authHost`, `port`, `databaseConfig`, and `sslCertPath`. Environment variables can override some options.

Demonstrates global installation, initialization, API client setup, starting the server, and basic client-side listening using Laravel Echo.

npm install -g laravel-echo-server # Navigate to your Laravel project root cd my-laravel-app # Initialize the configuration file. Follow prompts. # This creates laravel-echo-server.json laravel-echo-server init # Add an API client for HTTP broadcasting (optional but recommended) # Replace APP_ID with your desired application ID laravel-echo-server client:add APP_ID # Start the server laravel-echo-server start // Example client-side setup with laravel-echo (in resources/js/bootstrap.js or similar) import Echo from 'laravel-echo'; import { io } from 'socket.io-client'; window.io = io; window.Echo = new Echo({ broadcaster: 'socket.io', host: window.location.hostname + ':6001' // Or your server's host/port }); // Listen for a public channel event window.Echo.channel('my-public-channel') .listen('MyEvent', (e) => { console.log('Received event:', e); });
laravel-echo-server --version
Debug
Known issues
breakingRedis prefixing functionality (added in v1.6.0) requires Laravel Framework version 6.5.2 or higher to operate correctly.
fix
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`.
affects: >=1.6.0
gotchaUsing `devMode: true` in production environments can lead to excessive logging, potentially exposing sensitive information or impacting performance. It's intended for debugging only.
fix
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.
affects: >=1.0.0
gotchaCORS configuration for the HTTP API (`apiOriginAllow`) is crucial for client-side applications to communicate with the server if they are hosted on different domains/ports. Misconfiguration can lead to blocked requests.
fix
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"]}`
affects: >=1.3.2
gotchaWhen using SSL (HTTPS/WSS), ensure `sslCertChainPath` is configured if your SSL certificate includes a chain. Forgetting this can lead to `ERR_CERT_AUTHORITY_INVALID` errors in clients.
fix
Provide the full path to your SSL certificate chain file in the `sslCertChainPath` option within `laravel-echo-server.json`.
affects: >=1.3.1
gotchaThe `authHost` setting must correctly point to your Laravel application's host for private and presence channel authentication. Incorrect values or missing `APP_KEY` in Laravel's `.env` can prevent authentication.
fix
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.
affects: >=1.0.0
Errors
Common errors & fixes
laravel-echo-server: command not found
The `laravel-echo-server` package was not installed globally or is not in your system's PATH.
fix
Install the package globally using `npm install -g laravel-echo-server` or `yarn global add laravel-echo-server`.
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
The Redis server is not running or the `databaseConfig.redis` settings in `laravel-echo-server.json` are incorrect.
fix
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`.
WebSocket connection to 'ws://localhost:6001/socket.io/?EIO=3&transport=websocket' failed: Error during WebSocket handshake: Unexpected response code: 403
Client-side authentication or API access issues. This could be due to incorrect `authHost`, missing API client ID/key, or CORS policy blocking the connection.
fix
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.
Error: Request to authentication endpoint returned error.
The Laravel authentication endpoint (`authEndpoint`) is unreachable, misconfigured, or not returning a successful authentication response for private/presence channels.
fix
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.
Upgrade
Version history
1.6.3latest on npm
Audit
Dependencies
laravel-echorequiredThis is the client-side JavaScript library that communicates with laravel-echo-server. While not a direct npm dependency of the server, it's a critical part of the ecosystem for client-side functionality.
socket.iorequiredThe core real-time communication library used by laravel-echo-server for WebSocket connections.
redisoptionalRequired for Redis database backend to store presence channel members and for broadcasting events from Laravel to the Echo server.
laravel/frameworkrequiredThe Laravel PHP framework is required (version 5.3+ generally, 6.5.2+ for certain features like Redis prefixing) to provide the authentication endpoint and event broadcasting system that laravel-echo-server interacts with.
noderequiredLaravel Echo Server is a Node.js application and requires Node.js runtime (6.0+) to function.
Agent activity
2 hits · last 30 days
node
2
Resources
laravel-echo-server — npm install laravel-echo-server · libregistry