订阅私人频道的 Pusher Auth 值格式无效 'key:signature' (Laravel)

Pusher Auth value for subscription to private-channel has invalid format 'key:signature' (Laravel)

Pusher 工作,但停止了。 .env 设置是 100% 正确的。请告诉我如何调试这个?另外,我尝试制作新的 Puser 应用程序

Pusher : State changed : connecting -> connected with new socket ID 126791.4368004
pusher.min.js:8 Pusher : Event sent : {"event":"pusher:subscribe","data":{"auth":":88536630b30af895eb4ac1fcab4af7fcac1fbce3883074b00aa47cfc873c9362","channel":"private-user.1971"}}
pusher.min.js:8 Pusher : Event recd : {"event":"pusher:error","data":{"code":null,"message":"Auth value for subscription to private-user.1971 is invalid: should be of format 'key:signature'"}}
pusher.min.js:8 Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":null,"message":"Auth value for subscription to private-user.1971 is invalid: should be of format 'key:signature'"}}}
PUSHER_APP_ID=902144
PUSHER_APP_KEY=0dd4fc93384fc94b5d6b
PUSHER_APP_SECRET=*****************
var pusher = new Pusher('0dd4fc93384fc94b5d6b', {
    cluster: 'eu',
    forceTLS: true,
    auth: {
        headers: {
             'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
        }
    }
});
class PusherController extends Controller
{
    public $pusher;

    public function __construct ()
    {
        $this->middleware('auth');
        $this->pusher = new Pusher(env('PUSHER_APP_KEY'), env('PUSHER_APP_SECRET'), env('PUSHER_APP_ID'));
    }

    public function auth(Request $request)
    {
        if (Auth::check()) {
            return $this->pusher->socket_auth($request->get('channel_name'), $request->get('socket_id'));
        } else {
            return Response::make('Forbidden', 403);
        }
    }
}

Broadcasting.php:

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

一切正常,但在某个时候停止了。我很绝望:(

不要在配置文件之外使用 env(...)。使用 config(...) 参考您需要的文件和密钥。示例:config('broadcasting.pusher.key')

如果缓存配置,.env 文件不会加载,这意味着 env(...) returns null 的所有内容。

听起来你缓存了你的配置。您可以通过清除配置缓存来测试这个理论:

php artisan config:clear

如果它再次开始工作,那是你的问题。

"If you execute the config:cache command during your deployment process, you should be sure that you are only calling the env function from within your configuration files. Once the configuration has been cached, the .env file will not be loaded and all calls to the env function will return null."

Laravel 5.8 Docs - Configuration - Configuration Caching