Connection successful, but everything else (like subscribing to channels) fails
This is my setup:
Software: Laravel 5.8 Laravel websockets 1.1 Vue 2.6.10
Webserver: Debian 8 Plesk LetsEncrypt certificate
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'),
'host' => '127.0.0.1',
'port' => 6001,
'scheme' => 'https',
'curl_options' => [
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
]
],
],
websockets.php:
`'ssl' => [ /* * Path to local certificate file on filesystem. It must be a PEM encoded file which * contains your certificate and private key. It can optionally contain the * certificate chain of issuers. The private key also may be contained * in a separate file specified by local_pk. */ 'local_cert' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT', null),
/*
* Path to local private key file on filesystem in case of separate files for
* certificate (local_cert) and private key.
*/
'local_pk' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_PK', null),
/*
* Passphrase for your local_cert file.
*/
'passphrase' => env('LARAVEL_WEBSOCKETS_SSL_PASSPHRASE', null),
'verify_peer' => false,
],`
bootstrap.js:
// Web sockets
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: '.........',
wsHost: window.location.hostname,
wsPort: 6001,
wssPort: 6001,
encrypted: true,
disableStats: true,
enabledTransports: ['ws', 'wss'],
auth: {
headers: {
'X-CSRF-TOKEN': window.App.csrfToken,
},
},
})
Console output:
New connection opened for app key 7d23096ae0ab2d02d220.
Connection id 410216230.877411382 sending message {"event":"pusher:connection_established","data":"{\"socket_id\":\"410216230.877411382\",\"activity_timeout\":30}"}
However, I can't get listening to channels working. I do not get any console output on subscribing or anything else.
Echo.private('notifications.' + this.user.id)
.listen('MessageNotificationSent', (e) => { console.log(e) })
I feel like I already tried everything I could find on the Internet. Do you have any idea what I could try?
I also opened a thread on stackoverflow.
I've got the same issue. I can connect to the websocket server however the client won't join the presence channel. I can join a normal channel but that won't help me too much in this case.
Did you manage to fix your problem?
@KlaasT Take a look on the stackoverflow thread. Your problem sounds different than mine, because I cannot join any channels whatsoever.
Okay. I can use .channel('something'), .private and .join are not functioning. Currently I'm searching for some way to debug all this.
@KlaasT Okay, you have the exact same problem like me. I just tried and .channel is working for me too. At least we`re 2 now. So what now? 🤔 I am going to close this issue and open a new one describing the problem. Or did you already do that?
@Hillcow I managed to solve my problem. Under config/app.php my Broadcasting was commented out for some reason. After enabling again the private and presence channels worked.
@KlaasT not the case for me unfortunately 😞
I found the problem.
I had this in my web.php:
Route::post('/broadcasting/auth', function (Illuminate\Http\Request $req) {
if ($req->channel_name == 'users') {
return Broadcast::auth($req);
}
});
I don't exactly remember why and when I added this, but it was probably from here. Anyway, I got rid of this and now it´s working like a charm.