Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Problem connecting to Private Channels #896

Closed
@LJGrant

Description

@LJGrant

Using Laravel 8 I've been trying to set up a private channel connection. I've gotten regular channels to connect just fine, but when I try to set up a private connection, I get a 500 error from my auth route with this error:
Attempt to read property "key" on null {"exception":"[object] (ErrorException(code: 0): Attempt to read property \"key\" on null at /home/user/api/vendor/beyondcode/laravel-websockets/src/Dashboard/Http/Controllers/AuthenticateDashboard.php:27)

Connection setup:

 window.Echo = new Echo({
    broadcaster: "pusher",
    key: `${key}`,
    wsHost: `${host}`,
    wsPort: `${port}`,
    forceTLS: false,
    disableStats: true,
    encrypted: false,
    authEndpoint: `${authEndpoint}`,
    auth: {
      headers: {
        Authorization: `Bearer ${token}`,
      },
    },
  });

...

window.Echo.private(`scaledata.${selectedScale.id}`).listen(
          "ScaleEvent",
          (e) => {
            console.log(e);
          }
        ); 

route setup:

Broadcast::routes();
Broadcast::channel('scaledata.{scaleId}', function ($user, $scaleId){
    return Scale::where('id', $scaleId)->exists();
});

I've tried using different versions of laravel-websockets and pusher/pusher-php-server but every time I get the same error.
As far as I can tell I have everything configured correctly according to any documentation I can find but I can't find any solution for this for the life of me.

Any help would be highly appreciated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions