BroadcastException thrown on production server, but works on local machine #154
Description
I've spent my whole day trying to solve this.
I am using redis as queue connection. I have an event TestUpdated
which I am broadcasting on test.{id}
private channel. The event gets fired and caught by the client properly when I am on a local machine. But on production server (forge), I get BroadcastException
when TestUpdated
is fired:
Illuminate\Broadcasting\BroadcastException in /home/forge/mydomain.com/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php:117
apps
and ssl
config in websockets.php
:
'apps' => [
[
'id' => env('PUSHER_APP_ID'),
'name' => env('APP_NAME'),
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'enable_client_messages' => true,
'enable_statistics' => false,
],
],
'ssl' => [
'local_cert' => env('LOCAL_CERT', null),
'local_pk' => env('LOCAL_PK', null),
'passphrase' => null,
'verify_peer' => false,
],
pusher
config in broadcasting.php
:
'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' => '127.0.0.1',
'port' => 6001,
'scheme' => env('PUSHER_SCHEME'),
'curl_options' => [
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
],
],
],
The relevant environment variables in .env
:
PUSHER_APP_ID=someId
PUSHER_APP_KEY=someKey
PUSHER_APP_SECRET=someSecret
PUSHER_APP_CLUSTER=mt1
PUSHER_SCHEME=https
LOCAL_CERT=/etc/nginx/ssl/mydomain.com/123456/server.crt
LOCAL_PK=/etc/nginx/ssl/mydomain.com/123456/server.key
Client-side configuration:
window.Echo = new Echo({
authEndpoint: 'my/endpoint',
broadcaster: 'pusher',
key: 'someKey',
wsHost: process.env.NODE_ENV == 'development' ? window.location.hostname : 'mydomain.com',
wsPort: 6001,
wssPort: 6001,
disableStats: true,
encrypted: process.env.NODE_ENV == 'development' ? false : true
});
Strangely, the presence channel works (could this be related to #149 ?). It's only the broadcasting that seems to be failing.
How do I fix this?