Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
graphem opened this issue Sep 15, 2024 · 12 comments · Fixed by #50
Assignees
Labels
bug Something isn't working. It's clear that this does need to be fixed.

Comments

@graphem
Copy link

graphem commented Sep 15, 2024

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
Copy link
Collaborator

sacOO7 commented Sep 15, 2024

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
Copy link
Author

graphem commented Sep 15, 2024

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

@sacOO7
Copy link
Collaborator

sacOO7 commented Sep 15, 2024

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

Thanks, that would be super useful 👍

@graphem
Copy link
Author

graphem commented Sep 15, 2024

@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
Copy link
Collaborator

sacOO7 commented Sep 15, 2024

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

@sacOO7 sacOO7 self-assigned this Sep 16, 2024
@sacOO7 sacOO7 added the bug Something isn't working. It's clear that this does need to be fixed. label Sep 16, 2024
@graphem
Copy link
Author

graphem commented Sep 19, 2024

@sacOO7 Were you able to reproduce?

@sacOO7
Copy link
Collaborator

sacOO7 commented Sep 19, 2024

Hi @graphem I was able to reproduce the issue. Although, I had to manually edit the db for rooms ( by following original video series from source ) Btw, does this code work properly for reverb?

@sacOO7
Copy link
Collaborator

sacOO7 commented Sep 19, 2024

Seems I have found out the issue. This also needs sending clientId as per https://ably.com/docs/channels#publish-on-behalf. Currently, we are only sending connectionKey. This will work when user is not logged in. But for logged in user, we need to send clientId as well. This will require updating both laravel-broadcaster and laravel-echo packages. We should be able to update the same in next few days 👍

@graphem
Copy link
Author

graphem commented Sep 19, 2024

And yes the project works fine with Reverb.

@sacOO7
Copy link
Collaborator

sacOO7 commented Sep 26, 2024

Hi @graphem issue is fixed and released in latest versions of laravel-broadcaster and laravel-echo.

@sacOO7
Copy link
Collaborator

sacOO7 commented Sep 26, 2024

Btw, do star both repos if you feel like it : )

@graphem
Copy link
Author

graphem commented Sep 26, 2024

Amazing! Will test it out soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.
Development

Successfully merging a pull request may close this issue.

2 participants