我正在使用laravel-websockets软件包提供某些实时功能。我正在使用redis作为队列连接。我有一个事件TestUpdated
,该事件正在test.{id}
私人频道上播放。 当我在本地计算机上时,该事件会被客户端正确触发并捕获。但是在生产服务器上,我被抛出BroadcastException
:
/home/forge/mydomain.com/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php:117
中的Illuminate \ Broadcasting \ BroadcastException
Horizon仪表板还公开事件数据:
{
event: {
test: {
class: "App\Test",
id: 1,
relations: [
],
connection: "mysql"
},
socket: null
},
connection: null,
queue: null,
chainConnection: null,
chainQueue: null,
delay: null,
chained: [
]
}
我的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,
],
],
我的观察:
https
我正在使用任意推送程序应用程序ID,密钥和机密(someId,someKey和someSecret')。我的客户端配置:
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
});
来自broadcast.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')
],
],
我该如何解决?
答案 0 :(得分:0)
对于有相同问题的任何人:
我将主机更改为生产URL:
这是更新的配置:
'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' => env('PUSHER_HOST'),
'port' => 6001,
'scheme' => env('PUSHER_SCHEME')
],
],
在.env
文件中:
PUSHER_HOST=example.com
请记住从主机中排除http/https
。不是https://example.com
,而是example.com
。