0

I'm having problems connecting a project in Vue 3 with a Laravel websocket that is in Forge, I've tried all the ways, enabling and disabling settings, but the same error always returns:

Pusher error: cURL error 7: Failed to connect to 127.0.0.1 port 6001 after 0 ms: Connection refused

Below are the settings of my broadcasting.php:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Broadcaster
    |--------------------------------------------------------------------------
    |
    | This option controls the default broadcaster that will be used by the
    | framework when an event needs to be broadcast. You may set this to
    | any of the connections defined in the "connections" array below.
    |
    | Supported: "pusher", "ably", "redis", "log", "null"
    |
    */

    'default' => env('BROADCAST_DRIVER', 'null'),

    /*
    |--------------------------------------------------------------------------
    | Broadcast Connections
    |--------------------------------------------------------------------------
    |
    | Here you may define all of the broadcast connections that will be used
    | to broadcast events to other systems or over websockets. Samples of
    | each available type of connection are provided inside this array.
    |
    */

    'connections' => [

        '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' => true,
                'encrypted' => true,
                'host' => '127.0.0.1',
                'port' => 6001,
                'scheme' => 'http'
            ],
            'client_options' => [
                // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
            ],
        ],

        'ably' => [
            'driver' => 'ably',
            'key' => env('ABLY_KEY'),
        ],

        'redis' => [
            'driver' => 'redis',
            'connection' => 'default',
        ],

        'log' => [
            'driver' => 'log',
        ],

        'null' => [
            'driver' => 'null',
        ],

    ],

];

I tried to change the IP settings in Nginx from forge but similarly it didn't work

  • Who is failing, PHP or Vue? And, unless you have a Pusher service (I think it is only online, you have to pay for it, you can't download their service), you have to put their IP/config, not your local IP, why did you think putting that would work? Where did you see that (I may be wrong)? – matiaslauriti Mar 29 '23 at 12:22

1 Answers1

0

modify your config/broadcast.php just where the pusher array is like this.

'pusher' => [
        'driver' => 'pusher',
        'key' => env('PUSHER_APP_KEY'),
        'secret' => env('PUSHER_APP_SECRET'),
        'app_id' => env('PUSHER_APP_ID'),
        'options' => [
            'host' => env('LARAVEL_WEBSOCKET_HOST'),
            'port' => env('LARAVEL_WEBSOCKET_PORT'),
            'cluster' => env('PUSHER_APP_CLUSTER'),
            'encrypted' => true,
            'useTLS' => false,
            'scheme' => 'http',
            'curl_options' => [
                CURLOPT_SSL_VERIFYHOST => 0,
                CURLOPT_SSL_VERIFYPEER => 0,
            ]
        ],
        'client_options' => [
            // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
        ],
    ],

modify your .env like this. the major problem is replacing (127.0.0.1) with your-pc-ip-address:

PUSHER_APP_ID=local
PUSHER_APP_KEY=local
PUSHER_APP_SECRET=local
PUSHER_SCHEME=http
PUSHER_APP_CLUSTER=mt1

BROADCAST_DRIVER=pusher

LARAVEL_WEBSOCKET_HOST=Your-PC-IP-Address-goes-here
LARAVEL_WEBSOCKET_PORT=6001

modify your config/websockets.php like this

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

/*
 * This package comes with multi tenancy out of the box. Here you can
 * configure the different apps that can use the webSockets server.
 *
 * Optionally you specify capacity so you can limit the maximum
 * concurrent connections for a specific app.
 *
 * Optionally you can disable client events so clients cannot send
 * messages to each other via the webSockets.
 */
'apps' => [
    [
        'port' => env('LARAVEL_WEBSOCKETS_PORT', 6001),
        'host' => env('LARAVEL_WEBSOCKETS_HOST'),
        '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,
    ],
],