Мой файл reverb.php в моем каталоге config/ нетронут, так как я только что обновил .env.
Код: Выделить всё
QUEUE_CONNECTION=database
BROADCAST_CONNECTION=reverb
REVERB_APP_ID=12345
REVERB_APP_KEY=MYVERYSECRETKEY
REVERB_APP_SECRET=SUPERSECRET
REVERB_HOST="localhost"
REVERB_PORT=9090
REVERB_SCHEME=http
Код: Выделить всё
'default' => env('BROADCAST_DRIVER', 'null'),
Когда я запускаю php artisanchannel:list, я вижу Channel_for_everyone
При запуске в моем контейнере Docker php artisan reverb:start --debug Я вижу некоторые журналы проверки связи.
Код: Выделить всё
Connection Established ............ 310096377.635725104
Message Handled ................... 475763427.215883647
Message Received .................. 726544741.227378338
{
"event": "pusher:ping",
"data": []
}
Код: Выделить всё
Request URL: http://localhost:8000/broadcasting/auth
Request Method: POST
Status Code: 200 OK
Remote Address: [::1]:8000
Referrer Policy: strict-origin-when-cross-origin
Request URL: ws://localhost:9090/app/MYVERYSECRETKEY?protocol=7&client=js&version=8.4.0-rc2&flash=false
Request Method: GET OK
Status Code: 101 Switching Protocols
My Event, которая на данный момент действительно простой и перехватывается и регистрируется при запуске очереди: слушайте, но никогда не транслирует, хотя метод BroadcastOn() срабатывает, и я могу перехватить его с помощью dd()
Код: Выделить всё
class CommentCreatedEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public function __construct(
) {
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
//dd('inside broadcaseOn() in Event'); {
useEffect(() => {
console.log('Initialising Echo...');
const pusher = Pusher; // we need to make an instance
const echoConfig = new Echo({
broadcaster: 'reverb',
key: import.meta.env.VITE_REVERB_APP_KEY,
wsHost: import.meta.env.VITE_REVERB_HOST,
wsPort: import.meta.env.VITE_REVERB_PORT,
forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
enabledTransports: ['ws', 'wss'],
authEndpoint: import.meta.env.VITE_AUTH_ENDPOINT,
});
// Listen for successful connection
echoConfig.connector.pusher.connection.bind('connected', () => {
console.log('Successfully connected to Echo server.');
});
// Listen for connection errors
echoConfig.connector.pusher.connection.bind('error', (error: any) => {
console.error('Error connecting to Echo server:', error);
});
console.log('Subscribing to channel...');
echoConfig.private('channel_for_everyone')
.listen('CommentCreatedEvent', (event: any) => {
console.log('Event received:', event);
});
}, []);
};
export default useLaravelEcho;
Код: Выделить всё
Initialising Echo...
useLaravelEcho.ts:32 Subscribing to channel...
useLaravelEcho.ts:24 Successfully connected to Echo server.
У кого-нибудь есть идеи?
Подробнее здесь: https://stackoverflow.com/questions/786 ... ith-docker