ably / laravel-broadcaster

Official Laravel Ably Broadcaster
https://laravel.com/docs/broadcasting
Apache License 2.0
45 stars 7 forks source link

Using ->toOthers() results in a "Ably error: Malformed message; invalid connectionKey" Same as issue 38 #48

Open graphem opened 3 days ago

graphem commented 3 days ago

Hi!

Seems I am getting this as well when using the method in Laravel. I have all the latest packages and Laravel 11 latest.

broadcast(new ChatMessageCreated($message))->toOthers();

Result in:

[2024-09-15 01:38:06] local.ERROR: Ably error: Malformed message; invalid connectionKey {"userId":1,"exception":"[object] (Illuminate\Broadcasting\BroadcastException(code: 0): Ably error: Malformed message; invalid connectionKey at /vendor/ably/laravel-broadcaster/src/AblyBroadcaster.php:187)

I check the X-Socket-Id, it is there. And the socket is in the payload sent to the Rest api

I am really not sure what causes this. I do see that have a couple of websocket initiating, I did connect to different channels as I have a channel fro chat, for announcement and for some other events.

So not sure why the socket id a invalid connectionkey.

I check both on the front end and in the AblyBroadcaster.php and the key are exactly the same.

┆Issue is synchronized with this Jira Task by Unito

sacOO7 commented 3 days ago

Hi @graphem thanks for raising the issue. Can you confirm you are using laravel-echo at client side? It will be great if you can create a dummy repo that can help us reproduce the issue. Then we can try to fix it ASAP.

graphem commented 3 days ago

Yes I am using Echo. I will see what I can do for the dummy repo. Thanks!

sacOO7 commented 3 days ago

Yes I am using Echo. I will see what I can do for the dummy repo. Thanks!

Thanks, that would be super useful 👍

graphem commented 2 days ago

@sacOO7 Here is the repo: https://github.com/graphem/build-a-realtime-chat-with-laravel-vue-and-pinia

You will need to run the migration and add a room in the DB, then visit the /rooms/{slug}. Then you will see the 500 happening on trying to publish a message.

Thanks!!

sacOO7 commented 2 days ago

@graphem thanks for creating the repo. We will try to reproduce from our side and post updates here