gpt4 book ai didi

php - PusherBroadcaster.php 第 106 行中的 Laravel Echo BroadcastException : Unknown auth_key

转载 作者:行者123 更新时间:2023-12-03 08:47:53 24 4
gpt4 key购买 nike

我在尝试广播事件时收到未知的 auth_key 错误。我尝试按照其他帖子中提到的那样更改我的集群,但没有用。我在 app.php 中有未注释的广播服务提供商。

.env

PUSHER_APP_ID=******
PUSHER_APP_KEY=******
PUSHER_APP_SECRET=******

配置/广播

 'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
],
],

\app\Events\MessagePosted.php

public function broadcastOn() {
return new PresenceChannel('chatroom');
}

\资源\ Assets \js\bootstrap.js

window.axios = require('axios');

window.axios.defaults.headers.common = {
'X-Requested-With': 'XMLHttpRequest'
};

import Echo from "laravel-echo"
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: '*****',
cluster: 'ap2',
encrypted: true
});

\资源\ Assets \js\app.js

const app = new Vue({
el: '#app',
data: {
messages: [],
usersInRoom: []
},
methods: {
addMessage(message) {
// Add to existing messages
this.messages.push(message);

// Persist to the database etc
axios.post('/messages', message).then(response => {
// Do whatever;
})
}
},
created() {
axios.get('/messages').then(response => {
this.messages = response.data;
});
Echo.join('chatroom')
.here((users) => {
this.usersInRoom = users;
})
.joining((user) => {
this.usersInRoom.push(user);
})
.leaving((user) => {
this.usersInRoom = this.usersInRoom.filter(u => u != user)
})
.listen('MessagePosted', (e) => {
this.messages.push({
message: e.message.message,
user: e.user
});
});
}
});

最佳答案

config/broadcasting 添加 'cluster' => 'us2', 'encrypted' => 在 'options' 中为 true

'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => 'us2',
'encrypted' => true
],
],

关于php - PusherBroadcaster.php 第 106 行中的 Laravel Echo BroadcastException : Unknown auth_key,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44845616/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com