Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Pusher Presence Channel Auth error

Tags:

laravel

pusher

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.

like image 432
xuanyue Avatar asked May 01 '16 05:05

xuanyue


1 Answers

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

like image 118
Moritur Avatar answered Oct 18 '22 15:10

Moritur