I have the following in 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", "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,
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
'log' => [
'driver' => 'log',
],
'null' => [
'driver' => 'null',
],
'internal_chat_pusher' => [
'driver' => 'pusher',
'key' => env('INTERNAL_CHAT_PUSHER_APP_KEY'),
'secret' => env('INTERNAL_CHAT_PUSHER_APP_SECRET'),
'app_id' => env('INTERNAL_CHAT_PUSHER_APP_ID'),
'options' => [
'cluster' => env('INTERNAL_CHAT_PUSHER_APP_CLUSTER', 'ap2'),
'useTLS' => true,
]
],
],
];
then in my controller I try to use 'internal_chat_pusher' driver as follow:
public function send(Request $request)
{
$message = Message::create([
'from' => auth()->id(),
'to' => $request->contact_id,
'text' => $request->text
]);
// $internal = Broadcast::driver();
\Config::set('broadcasting.default', 'internal_chat_pusher');
broadcast(new NewMessage($message));
\Config::set('broadcasting.default', 'pusher');
return response()->json($message);
}
in my JavaScript I try to subscribe user to channel using the following:
window.Echo = new Echo({
broadcaster: 'pusher',
driver: 'internal_chat_pusher',
key: 'xxx',
cluster: 'ap2',
encrypted: true
});
but I get in Pusher debug console:
Invalid key in subscription auth data: 'xxxx'
here is my channels.php:
<?php
/*
|--------------------------------------------------------------------------
| Broadcast Channels
|--------------------------------------------------------------------------
|
| Here you may register all of the event broadcasting channels that your
| application supports. The given channel authorization callbacks are
| used to check if an authenticated user can listen to the channel.
|
*/
Broadcast::channel('messages.{id}', function ($user, $id) {
return $user->id === (int) $id;
});
I guess the problem is related to something like the authentication and authorization are done aginst the 'pusher' driver not 'internal_chat_pusher' because when I set the key in echo to be the one in pusher I get subscribed successfully, so, how to solve this problem please?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3cerb4L
via IFTTT
Aucun commentaire:
Enregistrer un commentaire