0

am using beyondcode laravel websocket beyondcode/laravel-websockets": "^1.14", which is the replacement for pusher, php pusher pusher/pusher-php-server": "^7.2" laravel echo "laravel-echo": "^1.15.0", and vite for react since frontend is react "@vitejs/plugin-react": "^3.0.0", which i have used to develop a real time chat application.

here is my setup

my env setting

PUSHER_APP_ID=some_id
PUSHER_APP_KEY=some_app_key
PUSHER_APP_SECRET=some_secrete
PUSHER_HOST="https://example.com"
PUSHER_PORT=6001
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1

my echo setting inside bootstrap.js setting

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,
    wsHost: import.meta.env.VITE_PUSHER_HOST,
    wssHost:import.meta.env.VITE_PUSHER_HOST,
    wsPort: import.meta.env.VITE_PUSHER_PORT,
    wssPort: import.meta.env.VITE_PUSHER_PORT,
    // disableStats:true,
    forceTLS: true, //since its on ssl 
    encrypted:true, //since its on ssl 
    enableTransports:['ws','wss'],
    auth:{
        headers:{
            'XSRF-TOKEN': '{{csrf_token()}}'
        }
    }
});

my broadcasting connection setting

'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'),
                'encrypted' => true,
                'host' => env(PUSHER_HOST),
                'port' => env(PUSHER_PORT),
                'scheme' => env(PUSHER_SCHEME)
            ],
        ],
]

my websocket setting

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

with these settings, when i run then same on localhost changing host to 127.0.0.1 it is working just fine but when i deploy it on a live web server and getting the following errors

  1. when i want to connect in the https://example.com/laravel-websocket which is the dashboard for the web socket am getting channel current state is unavailable error on click connect
  2. after clicking on connect in the console am getting pusher.min.js:8 WebSocket connection to 'wss://example.com:6001/app/some_app_key?protocol=7&client=js&version=4.3.1&flash=false' failed:

can anyone have a clue to solve these issues since i can not connect to the dashboard therefore i can not send or receive real time chats

i tried replacing the domain with my public address but still not wroking i tried to turn forceTLS: true, encrypted:true, to false

Isaacs
  • 1
  • 2

0 Answers0