Reverb + Herd not working after Shift from Laravel 10.x to 11.x
I was able to use Reverb locally until I recently did a Shift from Laravel 10.x to 11.x
I've tried:
Reinstalling Reverb in my app - walked through all the setup
Removed and recreated the Reverb service in Herd
I'm not using SSL locally for Reverb
I've tried setting the REVERB_HOST to either "0.0.0.0" or "myapp.test" (I was using myapp.test before and that was working)
Testing communication in Brave, shields off, incognito windows to avoid any cookie issues. I've also tested in FF and Safari.
Also experimented shutting off the Herd service and tried using the php artisan reverb:start command - nothing I've tried has worked.
There are no errors in the console - not even the usual "Websock failed". There's just no errors whatsoever.
I also did remove DispatchesJobs from app/Http/Controllers/Controller.php - but Ive tried it with and without that code and it made no difference. Also, dispatch is still available from the controller, so I assume it is fine to remove it as it does not exist in the slimmed down Laravel project.
Any help would be much appreciated - I'm not really familiar with troubleshooting Reverb or Herd issues. Thanks!
<?php
use App\Models\User;
use Illuminate\Support\Facades\Broadcast;
Broadcast::channel('branch.{id}', function (User $user, int $id) {
return (int) $user->branch_id === (int) $id;
});
It seems like you've already tried a number of troubleshooting steps to get Reverb working with Laravel 11.x. Here are a few additional steps you can take to diagnose and potentially solve the issue:
Check Laravel Upgrade Guide: Ensure that you have followed all the steps in the Laravel upgrade guide from 10.x to 11.x, as there might be breaking changes affecting Reverb or Herd.
Check Reverb and Herd Compatibility: Verify that the versions of Reverb and Herd you are using are compatible with Laravel 11.x. You may need to update these packages to versions that support Laravel 11.x.
Clear Configuration Cache: Sometimes, configuration values might be cached. Clear the cache to ensure Laravel is using the latest .env settings:
php artisan config:clear
Check for JavaScript Errors: Since Reverb involves real-time WebSocket communication, make sure there are no JavaScript errors in the browser that could be preventing the connection from being established.
Check Network Activity: Use the browser's developer tools to monitor WebSocket connections under the Network tab. This can give you insight into whether the connection is being attempted and if there are any responses.
Review Laravel Logs: Check the Laravel logs for any errors that might not be showing up in the console. The logs can be found in the storage/logs directory.
Test with Tinker: Use Laravel Tinker to manually dispatch an event and see if it's being broadcasted as expected:
php artisan tinker
event(new App\Events\YourEventNameHere);
Review Event Service Provider: Ensure that your EventServiceProvider is properly set up to register your events and listeners.
Check Queue Worker: If you're using queues to broadcast events, make sure your queue worker is running and processing jobs:
php artisan queue:work
Review Herd Configuration: Double-check the Herd configuration to ensure it's set up correctly and that there are no conflicts with other services.
Environment File: Make sure there are no quotes around the IP address in the .env file:
REVERB_HOST=0.0.0.0
Firewall or Port Issues: Ensure that the port you are using for Reverb is open and not blocked by any firewall settings.
If none of these steps resolve the issue, it might be helpful to reach out to the maintainers of Reverb and Herd or check their respective documentation and release notes for any known issues with Laravel 11.x. Additionally, consider asking for help on the Laravel Discord or other community forums where you might find others who have encountered and solved similar issues.
Taking the advice of Lary AI - I looked at the WS tab in the browser - seems like the Websocket is connected.
So I assume maybe the issue is with the channels.php not registering - I have no idea how to check that. Do channels routes typically show up in php artisan route:list? I checked out the old branch and don't see it there so I assume not.
I can't imagine anything else in the underlying code is the problem as this was just working pre-shift. Also, I did the shift just to slim the skeleton of the project because for this project that matters to me. I was already on Laravel 11 with this working. This is a bit perplexing.
@Snapey I am using Reverb to do a refresh on an helpdesk ticket list when creating ticket in a CRM product. Currently, the refresh is not being triggered when creating new issues. The broadcast channel is scoped to a branch_id - which is essentially the multi-tenancy tenant id. I'm totally lost as to why this isn't working tbh.
@fylzero You probably need to trace it from source, so I assume you are firing an event when the ticket list is updated. Is that event code called? Does it correctly specify that it should be broadcast? Can you see that event being broadcast in reverb?
<?php
namespace App\Events;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class IssueEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public function __construct(public int $branchId)
{
//
}
public function broadcastOn(): array
{
return [
new PrivateChannel('branch.'.$this->branchId),
];
}
}
If is called in my controller:
IssueEvent::dispatch(auth()->user()->branch_id);
I do not see the event being broadcast in Reverb when checking the log in Herd nor do I see anything in the Network/WS tab other than the connection.
@AbdallahT I had this same issue, because I upgraded from Laravel 10 to Laravel 11 and Livewire 2 to Livewire 3 etc, rather than just starting from scratch like every single tutorial; nobody once mentioned this, thank you so much, I was beginning to think I should switch careers.
@creekmore108 I did get this solved eventually. I had to uninstall Herd, reboot, reinstall Herd. Use the reverb service and walk through the docs carefully. I don't know exactly what fixed it but I don't believe it was a code change. It was either the reinstall of Herd or something in the .env that fixed it.
Make sure to check the SSL/HTTPS setting. I do enable mine.
Herd installed with Reverb service installed in Herd