想和Pusher一起订阅私人频道。但是每次它尝试订阅时,我都会看到下面的错误。这是没有意义的,因为它显然是返回的信息。
Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":null,"message":"Auth info required to subscribe to private-sadfsadf"}}}通常,它将返回带有状态200的auth (如下)。
"{\"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
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}}'
}
}
});发布于 2018-10-23 22:00:14
我犯了这个错误,这是由BROADCAST_DRIVER设置为redis而不是pusher造成的。
发布于 2022-06-09 15:59:36
这是因为我的端点/pusher/auth以JSON格式返回签名。
所以,我改变了这个:
return $response对此:
return json_decode($response)注意:推送签名使用hash_hmac生成散列:您可以将entryPoint返回与
$sig = hash_hmac('sha256',$socket, $channelNam);
var_dump($sig);https://stackoverflow.com/questions/47215890
复制相似问题