7 Moving Parts Just to Send One Real-Time Message in Laravel
Raheel Shan
November 22nd, 2026 · 10 min read
The first time I added real-time to a Laravel app, the requirement was one line.
Show a notification in the browser without a page refresh.
Small feature. Big setup.
Before a single Laravel event reached the browser, I had seven separate pieces wired together.
The seven parts
On the Laravel side:
- A Laravel event implementing
ShouldBroadcast - A queue worker
- Redis
- A Redis client:
predis/predisor thephpredisextension - A WebSocket server
On the frontend:
laravel-echopusher-jsorsocket.io-client, depending on the setup
The full path looked like this:
Laravel event → queue → Redis/Pusher → WebSocket server → Echo → browser
None of these parts is hard on its own.
Getting all seven to keep working together is the hard part.
And when one of them stops, nothing tells you. The app keeps working. Pages load. Forms submit. Real-time just goes quiet.
No error on the page. No exception in the log. Just silence.
Option 1: Pusher
Pusher was the easiest place to start.
Create a Pusher app, put the credentials in .env, set the broadcaster, wire up Echo.
BROADCAST_DRIVER=pusher
PUSHER_APP_ID=...
PUSHER_APP_KEY=...
PUSHER_APP_SECRET=...
PUSHER_APP_CLUSTER=ap2
On Laravel 11 and later, the key is <code class="inline-code">BROADCAST_CONNECTION</code> instead of <code class="inline-code">BROADCAST_DRIVER</code>.
—
Frontend:
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';
window.Pusher = Pusher;
window.Echo = new Echo({
broadcaster: 'pusher',
key: import.meta.env.VITE_PUSHER_APP_KEY,
cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER,
});
It works. That is the whole point of Pusher.
No WebSocket server to run. No process to babysit.
The trade-off is just as clear. It is an external service, and the bill grows with your users. Connections, messages, plan limits — all of it becomes your problem as you scale.
For a small app, it doesn't matter.
For an app that is growing, it matters every month.
Option 2: laravel-websockets
Eventually I wanted the WebSocket server on my own infrastructure.
That is where beyondcode/laravel-websockets came in.
It speaks the Pusher protocol, so Echo and pusher-js stay almost the same. The only real change: the WebSocket server now runs on your box, not Pusher's.
Point the Pusher config at it:
// config/broadcasting.php
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'host' => '127.0.0.1',
'port' => 6001,
'scheme' => 'http',
'useTLS' => false,
],
],
Point Echo at it:
window.Echo = new Echo({
broadcaster: 'pusher',
key: import.meta.env.VITE_PUSHER_APP_KEY,
wsHost: window.location.hostname,
wsPort: 6001,
forceTLS: false,
disableStats: true,
enabledTransports: ['ws', 'wss'],
});
Then start one more process:
php artisan websockets:serve
This is the moment a small feature turns into an infrastructure job.
That server is its own process. If it dies, real-time dies. So now you need Supervisor to keep it alive.
Port 6001 has to be reachable, directly or through a reverse proxy.
If the app runs on HTTPS, the WebSocket has to run securely too, or the browser refuses to connect.
The thing that took me longest to accept: the app can be perfectly healthy while the WebSocket process is dead. Two separate things. Two separate failures.
Option 3: laravel-echo-server
The other route was laravel-echo-server.
Here the WebSocket server is Node.js, and Redis sits between Laravel and Node.
Laravel broadcasts to Redis:
BROADCAST_DRIVER=redis
REDIS_CLIENT=predis
Install and run the Echo server separately:
npm install -g laravel-echo-server
laravel-echo-server init
laravel-echo-server start
Frontend:
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',
});
The path becomes:
Laravel → Redis → Node.js Echo Server → browser
It works too.
But count what is running now: PHP, Node.js, Redis, a queue worker and a WebSocket server. Two runtimes for one notification.
For a Laravel app, that is a lot of infrastructure just to push a message to a browser.
Both <code class="inline-code">laravel-websockets</code> and <code class="inline-code">laravel-echo-server</code> are no longer maintained today. Laravel Reverb took their place. We will get there later in the series — but the problems below still apply to any self-hosted setup.
—
Side by side
| Setup | What you run besides Laravel |
|---|---|
| Pusher | Queue worker + Pusher account |
| laravel-websockets | Queue worker + WebSocket process + Supervisor |
| laravel-echo-server | Queue worker + Redis + Node.js process + Supervisor |
Pusher is the simplest to run.
Self-hosting gives you control. It also hands you every process on that list.
That is where my real problems started.
The bugs were almost never in Laravel
Laravel would be working perfectly. Real-time would still be broken.
Some of the ones that got me:
- Queue worker stopped. The event fired correctly. Nothing was broadcast.
- WebSocket process died. The site was fine. Users just stopped getting updates.
- Private channel returned
403./broadcasting/authwas running through the wrong middleware. - Browser blocked
ws://. The app was onhttps://. - Deploy restarted PHP but not the WebSocket server. It kept running old code.
Every one of these was easy to fix.
Every one of them was hard to find.
A normal Laravel request gives you a response — success or error, you see it. A WebSocket setup has several processes, and any of them can fail while the main app looks completely healthy.
And then the second problem
By now I had server-to-browser working. Laravel broadcasts, the browser receives.
That is one direction.
What about the browser talking back?
- A user starts typing in a chat
- A cursor moves
- A user sends a message
- One browser needs to notify another
- The server needs to receive live data and store it
Echo has whisper() for client-to-client events.
But a whisper never reaches Laravel. It goes from one browser, through the WebSocket server, to the other browsers. Your controllers never see it. Your database never sees it.
If the server needs to act on that data, whispers don't help.
I had worked with SignalR before. There, the client calls a method on the hub and the server handles it. Simple, two-way, built in.
Laravel's WebSocket ecosystem didn't give me that out of the box.
So I had to build my own way.
That is where the next article starts.
Next: Why Laravel Echo Whispers Never Reach Your Server
Comment "WHISPER" if you've hit the same wall.
Found this useful?
Support the work that goes into these posts.