xuanyue
xuanyue

Reputation: 1428

Laravel Pusher Presence Channel Auth error

I'm trying to build a presence channel. But the auth string returned is not correct.

Here is the back end code:

class pusherController extends Controller
{

    protected $pusher;

    public function __construct(PusherManager $pusher)
    {
        $this->pusher = $pusher;
    }

    public function pusherPinyinAuth(Request $request)
    {
        if($request->user()) {
            $user = $request->user();
            $auth= $this->pusher->presence_auth($request->input('channel_name'),$request->input('socket_id'), $user->id, array('h'=>'user_info'));
            return response($auth);
        }
    }
}

Error message

Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":null,"message":"Auth value for subscription to presence-5 is invalid: should be of format 'key:signature'"}}}

I guess the the error is caused by the additional ':' added before the auth string. But I manually remove that it still report the same error. Here is my string output:

{auth: ":8dacf362f8fe62bae42c33dfe5511d3d1c42144685d5843a6a6a8014490ed0f6",…}

I'm using the pusher bridge from https://github.com/vinkla/pusher

I'd like to try the official pusher-php-server, but after composer install, I don't know how to use it in my code. I want to know whether https://github.com/pusher/pusher-http-php have the same issue.

Upvotes: 6

Views: 3345

Answers (2)

Olaboye David Tobi
Olaboye David Tobi

Reputation: 139

I also face this same error

Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":null,"message":"Auth value for subscription to presence-5 is invalid: should be of format 'key:signature'"}}}

I was able to resolve this by returning an array containing the user details in the channel.php file

see code sample below: channel.php

Broadcast::channel('request_channel', function ($user) {
    return  ['id' => $user->id, 'name' => $user->name];
});

Upvotes: 0

Moritur
Moritur

Reputation: 1748

For me this was caused by the pusher key, secret and app_id values not being set correctly in production.

Upvotes: 5

Related Questions