尝试使用 Pusher 订阅私有(private) channel 。但每次尝试订阅时,我都会收到以下错误。这没有任何意义,因为它显然返回了身份验证信息。
Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":null,"message":"Auth info required to subscribe to private-sadfsadf"}}}
通常它会返回状态为 200
的 auth json(如下)。
"{\"auth\":\"0b1ce844906bd4d82cb4:21571e5667bf99f17bbf67ae0411594560748fde30b9edeca653653158f8a1f5\"}"
Pusher PHP(缩短)
$pusher = new Pusher($app_key, $app_secret, $app_id);
$auth = $pusher->socket_auth($postvars['channel_name'], $postvars['socked_id']);
if ($auth)
return $response->withJSON($auth);
else
return $response->withStatus(403);
Pusher JS
var pusher = new Pusher('0b1ce844906bd4d82cb4', {
cluster: 'us2',
encrypted: true,
authEndpoint: '{{site.uri.public}}/chat/auth/{{game.id}}',
authTransport: 'ajax',
auth: {
params: {
'csrf_name': '{{site.csrf.name}}',
'csrf_value': '{{site.csrf.value}}'
},
headers: {
'{{site.csrf.name}}': '{{site.csrf.value}}'
}
}
});
最佳答案
我遇到了这个错误,这是由于将 BROADCAST_DRIVER 设置为 redis 而不是 Pusher 造成的。
关于php - 订阅 private-asdf 所需的 Pusher 私有(private) channel 身份验证信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47215890/