2

I'm following this package intructions: https://beyondco.de/docs/laravel-websockets/getting-started/introduction

I'm using laravel forge to deploy and projects works fine in localhost but doesn't work after deploying to laravel forge

enter image description here

Here is my code websocket.php

        [
            '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

            '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' => 'https'
            ],
        ],

.env

PUSHER_APP_KEY=anyKey
PUSHER_APP_SECRET=anySecret
PUSHER_APP_CLUSTER=mt1

bootstrap.js


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

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    forceTLS: false,
    wsPort: 6001,
    wssPort: 6001,
    enabledTransports: ['ws', 'wss'],
    wsHost: window.location.hostname,
});

broadcasting route

Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
    return (int) $user->id === (int) $id;
});

Broadcast::channel('user-{user_id}-exe', function($user, $user_id) {
    return $user->id == $user_id;
});

composer.json

"beyondcode/laravel-websockets": "^1.12",
"pusher/pusher-php-server": "^5.0", 

What am I doing wrong?

maybe i think this issue for "wss"

Istiake
  • 41
  • 1
  • 7

3 Answers3

1

It was solved for me

.env

BROADCAST_DRIVER=pusher
PUSHER_APP_ID="test"
PUSHER_APP_KEY="test"
PUSHER_APP_SECRET="test"
PUSHER_APP_CLUSTER="test"

at the end

php artisan optimize:clear
Daniel
  • 11
  • 1
0

In broadcasting.php file comment useTLS

'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,
    'host' => '127.0.0.1',
    'port' => env('LARAVEL_WEBSOCKETS_PORT', 6001),
    'scheme' => 'http'
  ],
],
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
0
'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'),
            'host' => '127.0.0.1',
            'port' => env('LARAVEL_WEBSOCKETS_PORT', 6001),
            'useTLS' => true,
            'scheme' => 'http',
            'curl_options' => [
                CURLOPT_SSL_VERIFYHOST => 0,
                CURLOPT_SSL_VERIFYPEER => 0,
            ]
        ],
    ],
Saeid
  • 1,269
  • 1
  • 9
  • 12