-
Notifications
You must be signed in to change notification settings - Fork 98
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
Reverb not sending any event to client #178
Comments
You are broadcasting the event to a private channel (PrivateChannel) but you are listing on a public channel (Echo.channel()) Change PrivateChannel to Channel or change Echo.channel() to Echo.private() |
Thanks @sinnbeck |
@sinnbeck Thanks for the feedback. Replacing PrivateChannel to Channel doesnt seen to work either. As you can see in the image, the reverb server didn't send any mensage after the subscribe, even when the GotMessage was dispatched after that. And replacing <script>
window.addEventListener("load", function() {
window.Echo.private(`channel_for_everyone`)
.listen('GotMessage', (e) => {
console.log(e.order);
});
});
</script> I have found the repo of the laracast presentation of reverb. I will explore this repo and see if I can found whats wrong. *sorry for the images, i couldn't copy these output to paste as text. |
I cloned the repository "exploring-laravel-reverb" and only updated the reverb package (because of the #76 bug in windows), but didn't work for me either. Same behaviour as when I used I rec a video of my test: issue.mp4Am I missing something? 🤔 |
@crazynds do you see a request to the |
@joedixon Thanks for the reply. I will use the repo "exploring-laravel-reverb" as the reference here, because if I resolve the problem in the repo, I can resolve in the other too. When I enter in the dashboard and every action I do in the podcast screen the software calls The request:
The response is a empty body. |
It's not actually Reverb which handles that endpoint - it's part of the framework itself. Looks like that's why you're not able to auth with the private channel though. Did you run the |
Yes, if I run this command again this is the output. $ php artisan install:broadcasting
ERROR The 'broadcasting' configuration file already exists.
ERROR Broadcasting routes file already exists.
Would you like to install and build the Node dependencies required for broadcasting? (yes/no) [yes]
❯ no
But one think I notice with this comment is that if I change my broadcast route to: Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
dd('ok');
return (int) $user->id === (int) $id;
}); It didn't print the 'ok' debug message in the route /broadcast/auth. If I execute the command
But I don't understand why, even when the broadcast is installed. 🤔 |
Ok, now I get it, this is really my fault when I cloned the repo from laracast.
Should be:
This makes the response works. I only get this reading the source code of \Illuminate\Broadcasting\BroadcastController. Rereading the documentation of broadcasting I notice the only one driver that dont tell to change the .env variable Thanks for the time! @joedixon @driesvints @sinnbeck |
Maybe this env var should be setted in the reverb:install command or added to the docs. |
The When I get some time, I will pull down that example repo and give it a try. |
In my case it didn't get set because I deployed my project to production and when I did |
I tried it yesterday and when installing broadcasting, .env variables are created in .env but not in .env.example file. |
Reverb Version
v1.0.0-beta9
Laravel Version
v11.5.0
PHP Version
8.3.3
Description
I have setup a basic project following the steps to configure reverb and their functionalities, but nothing I do work to send any event to the client listening in the socket. The event is dispatched, and the client socket is connected in the reverb:start server, but when I dispatch some event, the worker show that it work in this event but the reverb dont show anything (with --debug flag) that it has sended the event to the clients, the only output log is over time the ping sended and recived.
I created a public repo with just a base laravel configuration and reverb that I'm using for this test to create a simple application to broadcast a message to all connected clients.
I'm using windows 11 if that change anything.
Steps To Reproduce
Create a clean laravel 11 project and add the basic auth ui and install:broadcast.
Create the following classes:
(Create the model Message with migrations, but not necessary to add the code in this issue)
Event:
Job:
Command to create a job to dispatch an event:
channels.php
In home.blade.php add the following script:
php artisan serve
php artisan reverb:start --debug
php artisan queue:listen
Go to dashboard page (Register + login)
On this screen you can use f12 to see if the socket is connected:
Run the command to send an event:
php artisan app:test
My thoughts
I think that the event is probably not being sent to the thread that is executing reverb:start, but I don't know how the events are dispatched between threads (whether via cache, database, filesystem,...). Without knowing how events are dispatched, I can't debug what my error might be.
I actually tried to make an laravel application from scratch following several tutorials, including the one on the official Laravel YouTube page, and with none of them I managed to get the event distributed via broadcast.
I'm 99.9% sure that it could be my error, but I've already reread the documentation and haven't had any success. The documentation for using broadcast is also very confusing as it is divided into 3 (Event Docs, Broadcast Docs and Reverb Docs), and makes it difficult to know what I am doing wrong.
The text was updated successfully, but these errors were encountered: