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

mathewparet's avatar

Need help debugging my broadcast config

My broadcasting seems to work when using Pusher, but seems like it doesn't work when trying to use Soketi:

.env when using Pusher

PUSHER_APP_ID=REDACTED
PUSHER_APP_KEY=REDACTED
PUSHER_APP_SECRET=REDACTED
PUSHER_APP_CLUSTER=REDACTED
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
MIX_PUSHER_HOST="${PUSHER_APP_HOST}"
MIX_PUSHER_PORT="${PUSHER_APP_PORT}"

.env when using Soketi

PUSHER_APP_ID=app-id
PUSHER_APP_KEY=app-key
PUSHER_APP_SECRET=app-secret
PUSHER_APP_SCHEME=http
PUSHER_APP_HOST=127.0.0.1
PUSHER_APP_PORT=6001
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
MIX_PUSHER_HOST="${PUSHER_APP_HOST}"
MIX_PUSHER_PORT="${PUSHER_APP_PORT}"

In both cases

bootstrap.js looks like:

import Echo from 'laravel-echo';

window.Pusher = require('pusher-js');

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    wsHost: process.env.MIX_PUSHER_HOST,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    forceTLS: false,
    wsPort: process.env.MIX_PUSHER_PORT,
    wssPort: process.env.MIX_PUSHER_PORT,
    encrypted: true,
    disableStats: true,
    enabledTransports: ['ws','wss'],
});

config/broadcasting.php looks like:

        'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => env('PUSHER_APP_CLUSTER'),
                'useTLS' => false,
                'host' => env('PUSHER_APP_HOST'),
                'port' => env('PUSHER_APP_PORT'),
                'scheme' => env('PUSHER_APP_SCHEME'),
            ],
        ],

Broadcasting: App\Notifications\DataExportCompletedNotification

class DataExportCompletedNotification extends Notification implements ShouldQueue
{
    use Queueable;
...
    public function __construct($model_name, $download_link)
    {
        $this->model_name = Str::plural($model_name);
        $this->download_link = $download_link;
    }

    public function via($notifiable)
    {
        return ['mail', 'broadcast'];
    }
...
    public function toBroadcast($notifiable)
    {
        return new BroadcastMessage([
            'text' => __("Data export for :Model completed", ['model'=>$this->model_name]),
            'link' => $this->download_link,
        ]);
    }

And this is how I listen to the channel:

<template>
    <div>
        You have {{this.notifications.length}} notifications
        <ol>
            <li v-for="notification in notifications" :key="notification.id">{{notification.text}} - {{notification.link}}</li>
        </ol>
    </div>
</template>
<script>
import { defineComponent } from 'vue'

export default defineComponent({
    data()
    {
        return {
            notifications : []
        };
    },
    mounted()
    {
        Echo.private('App.Models.User.'+this.$page.props.user.id)
            .notification((notification) => {
                this.notifications.push(notification);
            });
        console.log(Echo);
    }
})
</script>

Everything works well when using Pusher.

But when using Soketi I get the below error:

[2022-03-04 05:37:39] local.ERROR: Pusher error: cURL error 7: Failed to connect to 127.0.0.1 port 6001: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://127.0.0.1:6001/apps/app-id/events?auth_key=app-key&auth_timestamp=1646372259&auth_version=1.0&body_md5=817698c5c2e65c7d7237d30b07af0c50&auth_signature=2f3ca5b6f4c2fe2d94c431ce32ff1b4bc24b73ea4f9ddb7fd9582b4da83558bb. {"exception":"[object] (Illuminate\Broadcasting\BroadcastException(code: 0): Pusher error: cURL error 7: Failed to connect to 127.0.0.1 port 6001: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://127.0.0.1:6001/apps/app-id/events?auth_key=app-key&auth_timestamp=1646372259&auth_version=1.0&body_md5=817698c5c2e65c7d7237d30b07af0c50&auth_signature=2f3ca5b6f4c2fe2d94c431ce32ff1b4bc24b73ea4f9ddb7fd9582b4da83558bb. at /var/www/html/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php:128)

But curl on terminal seem to work:

mathewparet@gMac fifa % curl 127.0.0.1:6001
OK%                                                                                                                        
mathewparet@gMac fifa %  

I can confirm Soketi is running via sail

soketi_1        | 📡 soketi initialization....
soketi_1        | 
soketi_1        | ⚡ Initializing the HTTP API & Websockets Server...
soketi_1        | 
soketi_1        | ⚡ Initializing the Websocket listeners and channels...
soketi_1        | 
soketi_1        | ⚡ Initializing the HTTP webserver...
soketi_1        | 
soketi_1        | 🕵️‍♂️ Initiating metrics endpoints...
soketi_1        | 
soketi_1        | 🎉 Server is up and running!
soketi_1        | 
soketi_1        | 📡 The Websockets server is available at 127.0.0.1:6001
soketi_1        | 
soketi_1        | 🔗 The HTTP API server is available at http://127.0.0.1:6001
soketi_1        | 
soketi_1        | 🎊 The /usage endpoint is available on port 9601.
soketi_1        | 
soketi_1        | [Fri Mar 04 2022 05:17:39 GMT+0000 (Coordinated Universal Time)] Promoted from node to master.
soketi_1        | {
soketi_1        |   isMaster: true,
soketi_1        |   isMasterEligible: true,
soketi_1        |   weight: -0.1646371059265,
soketi_1        |   address: '127.0.0.1',
soketi_1        |   advertisement: undefined
soketi_1        | }

...

soketi_1        | [Fri Mar 04 2022 05:19:05 GMT+0000 (Coordinated Universal Time)] ⚡ New message received:
soketi_1        | { message: { event: 'pusher:ping', data: {} }, isBinary: false }
soketi_1        | [Fri Mar 04 2022 05:19:05 GMT+0000 (Coordinated Universal Time)] ✈ Sent message to client:
soketi_1        | {
soketi_1        |   ws: uWS.WebSocket {
soketi_1        |     ip: '172.29.0.1',
soketi_1        |     ip2: '',
soketi_1        |     appKey: 'app-key',
soketi_1        |     sendJson: [Function (anonymous)],
soketi_1        |     id: '5808201246.5634146053',
soketi_1        |     subscribedChannels: Set(1) { 'private-App.Models.User.1' },
soketi_1        |     presence: Map(0) {},
soketi_1        |     app: App {
soketi_1        |       hasClientEventWebhooks: false,
soketi_1        |       hasChannelOccupiedWebhooks: false,
soketi_1        |       hasChannelVacatedWebhooks: false,
soketi_1        |       hasMemberAddedWebhooks: false,
soketi_1        |       hasMemberRemovedWebhooks: false,
soketi_1        |       id: 'app-id',
soketi_1        |       key: 'app-key',
soketi_1        |       secret: 'app-secret',
soketi_1        |       maxConnections: -1,
soketi_1        |       enableClientMessages: false,
soketi_1        |       enabled: true,
soketi_1        |       maxClientEventsPerSecond: -1,
soketi_1        |       maxPresenceMembersPerChannel: 100,
soketi_1        |       maxPresenceMemberSizeInKb: 2,
soketi_1        |       maxChannelNameLength: 200,
soketi_1        |       maxEventChannelsAtOnce: 100,
soketi_1        |       maxEventNameLength: 200,
soketi_1        |       maxEventPayloadInKb: 100,
soketi_1        |       maxEventBatchSize: 10
soketi_1        |     },
soketi_1        |     timeout: Timeout {
soketi_1        |       _idleTimeout: 120000,
soketi_1        |       _idlePrev: [TimersList],
soketi_1        |       _idleNext: [TimersList],
soketi_1        |       _idleStart: 86160,
soketi_1        |       _onTimeout: [Function (anonymous)],
soketi_1        |       _timerArgs: undefined,
soketi_1        |       _repeat: null,
soketi_1        |       _destroyed: false,
soketi_1        |       [Symbol(refed)]: true,
soketi_1        |       [Symbol(kHasPrimitive)]: false,
soketi_1        |       [Symbol(asyncId)]: 224,
soketi_1        |       [Symbol(triggerId)]: 0
soketi_1        |     }
soketi_1        |   },
soketi_1        |   data: { event: 'pusher:pong', data: {} }
soketi_1        | }

And it is receiving and responding to pusher ping). But my broadcasts aren't working:

0 likes
2 replies
mathewparet's avatar

Fixed it - though don't know why using 127.0.0.1 as PUSHER_APP_HOST didn't work, but using soketi worked

Please or to participate in this conversation.