Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jaracas's avatar

Echo not even trying to connect to Websockets pusher server

I'm using Laravel 10 and:

composer.json

"beyondcode/laravel-websockets": "^1.14",
"pusher/pusher-php-server": "^7.2" // I've tried 7.0.2 as well

package.json

"laravel-echo": "^1.15.0",
"pusher-js": "^8.0.1",

My event:

<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class NewNotification implements ShouldBroadcastNow
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $notification;
    
    public function __construct($notification)
    {
        $this->notification = $notification;
    }

    public function broadcastAs(): string
    {
        return 'newnotification';
    }
    
    public function broadcastOn(): Channel
    {
        return new Channel('notifications');
    }
}

websockets.php

return [
    'dashboard' => [
        'port' => env('LARAVEL_WEBSOCKETS_PORT', 6001),
    ],

    'apps' => [
        [
            'id' => env('PUSHER_APP_ID'),
            'name' => env('APP_NAME'),
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'path' => env('PUSHER_APP_PATH'),
            'capacity' => null,
            'enable_client_messages' => false,
            'enable_statistics' => true,
        ],
    ],

broadcasting.php

        'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', //
                'port' => env('PUSHER_PORT', 443), //
                'scheme' => env('PUSHER_SCHEME', 'https'), //
                // 'encrypted' => true,
                // 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
            ],
            'client_options' => [
                // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
            ],
        ],

bootstrap.js

import Echo from 'laravel-echo';

import Pusher from 'pusher-js';

window.Pusher = Pusher;

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: "KEYKEYKEYKEY",
    wsHost: "domain.com",
    wsPort: 6001,
    wssPort: 6001, // import.meta.env.VITE_PUSHER_PORT ?? 443
    forceTLS: false,
    enabledTransports: ['ws', 'wss'],
});


Echo.channel('notifications')
    .listen('newnotification', (e) => {
        console.log(e);
    });

With that out of the way, I run the server and go to /laravel-websockets and connect. I then use Tinker + "event (new \App\Events\NewNotification('test'))" and when I check the/laravel-websockets panel it sees the message: "api-message Channel: notifications, Event: newnotification". However there's nothing in the console on the actual site that bootstrap.js is loaded on. It connects to a websocket server (Status 101, but it looks like it connects on port 5173...? So probably not it now that I"m thinking about it), but I don't get any console messages.

What's going on? I tried using pusher-php-server 7.0.2 as suggested by a few people, but I also tried 7.2 since it looks like that bug has been fixed (According to changelogs at least).

0 likes
2 replies
LaryAI's avatar
Level 58

It looks like you have everything set up correctly, but it's possible that the port you are using is incorrect. Try changing the wsPort and wssPort in your bootstrap.js file to 443 and see if that helps. If that doesn't work, you may need to check your firewall settings to make sure that the port is open and accessible.

You can also try running the php artisan websockets:serve command to see if that helps.

jaracas's avatar

Figured it out, needed to add

cluster: 'eu',

To the echo config

Please or to participate in this conversation.