Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tikey23's avatar

Broadcasting/auth not called on production

Hello everyone,

I have created a private chat with reverb, which is working fine. Now on production I can send messages in the chat, but the message is not received in the browser on both participants. The POST-Request to /broadcasting/auth is made and I get 200 response (without any body - which seems ok). Payload is: socket_id: 342326825.464027801 and channel_name: private-chat.1-2

But it looks like the the route in channels.php is never called:

Broadcast::channel('chat.{user1Id}-{user2Id}', function (\App\Models\User $user, $user1Id, $user2Id) {
    Log::info('Channel chat.{id1}-{id2} reached!', ['id1' => $user1Id, 'id2' => $user2Id]); // Log zur Bestätigung
})

The javascript looks like:


 let rawChannelName  = 'chat.' + Math.min(loggedInUserId, chatPartnerId) + '-' + Math.max(loggedInUserId, chatPartnerId);
        Echo.private(rawChannelName)
            .listen('NewChatMessage', (event) => {
                console.log('Nachricht empfangen:', event);
                Livewire.dispatch('newMessageReceived', event);
				setTimeout(scrollToBottom, 500);

  GET|POST|HEAD       broadcasting/auth ......................................................................................... Illuminate\Broadcasting › BroadcastController@authenticate
                      ⇂ App\Http\Middleware\EncryptCookies
                      ⇂ Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse
                      ⇂ Illuminate\Session\Middleware\StartSession
                      ⇂ Illuminate\View\Middleware\ShareErrorsFromSession
                      ⇂ App\Http\Middleware\Authenticate:web
                      ⇂ Illuminate\Routing\Middleware\SubstituteBindings

I have no clue why it is working locally but not on the server. Have you any suggestions?

0 likes
2 replies
LaryAI's avatar
Level 58

Certainly! This is a common issue when deploying Laravel broadcasting to production, especially when using private channels and custom authorization logic. Here are some steps and checks to help you debug and resolve the issue:


1. Check Cache

In production, Laravel often caches routes, config, and sometimes even the broadcasting channels. If you made changes to routes/channels.php and did not clear the cache, your new logic may not be picked up.

Solution: Run these commands on your production server:

php artisan route:clear
php artisan config:clear
php artisan cache:clear
php artisan view:clear

2. Logging in Production

You mentioned that your Log::info() is not being hit. In production, check your log files (usually in storage/logs/laravel.log). Make sure your logging level is set to info or lower in your .env:

LOG_LEVEL=info

3. Authentication Middleware

The /broadcasting/auth route uses the Authenticate:web middleware by default. In production, if your session or authentication is not working as expected (e.g., due to domain, HTTPS, or cookie issues), the user may not be authenticated, and the closure in channels.php will not be called.

Check:

  • Are you using the same domain for your API and frontend?
  • Are cookies being sent correctly?
  • Is your session driver working in production?

4. Channel Name Consistency

Double-check that the channel name generated in JavaScript matches exactly with the one defined in channels.php. For example, if your JS generates chat.1-2, your channel definition must be:

Broadcast::channel('chat.{user1Id}-{user2Id}', function ($user, $user1Id, $user2Id) {
    // logic
});

5. CSRF and HTTPS Issues

If your production site is running over HTTPS, make sure your broadcasting client (e.g., Laravel Echo) is also using HTTPS and that CSRF tokens are being sent correctly.


6. Check Broadcasting Driver

Ensure your .env is set to use the correct broadcasting driver in production. For example, if you use Pusher or Laravel Reverb:

BROADCAST_DRIVER=reverb

And that your broadcasting config is correct.


7. Debugging the Auth Closure

Add more logging or even a dd() in your channel closure to see if it's ever hit:

Broadcast::channel('chat.{user1Id}-{user2Id}', function ($user, $user1Id, $user2Id) {
    \Log::info('Channel closure hit', ['user' => $user->id, 'user1Id' => $user1Id, 'user2Id' => $user2Id]);
    // dd('Channel closure hit');
    return true;
});

8. Check for Caching in channels.php

If you deploy with php artisan config:cache or php artisan route:cache, remember that channels.php is NOT cached by route:cache, but if you have any config or environment variable logic in there, it may not be up-to-date. Always clear cache after deployment.


9. Check for Errors in Network Tab

In your browser's dev tools, check the response from /broadcasting/auth. If it's a 200 with an empty body, that's normal for a successful auth. But if it's a 403 or 401, it means the user is not authenticated.


10. Session Domain and Cookie Issues

If your app is on a subdomain or uses a different domain for API and frontend, make sure your SESSION_DOMAIN and SANCTUM_STATEFUL_DOMAINS (if using Sanctum) are set correctly in .env.


Summary Checklist

  • Clear all caches after deployment.
  • Check logs in production for any errors.
  • Ensure authentication is working in production.
  • Verify channel names match exactly.
  • Ensure broadcasting driver is set correctly.
  • Check for HTTPS and cookie issues.
  • Add logging or dd() in your channel closure to confirm it's being hit.

If after all these steps the closure is still not being called, please provide more details about your authentication setup (e.g., are you using Laravel Sanctum, Passport, or session-based auth?), and how your frontend is making requests (same domain, subdomain, etc.).

Let me know if you need more targeted help!

tikey23's avatar

just tried to solve the problem now 3 days with gemini. Checking all these generic tipps. Hope a real person can help.

How is it possible that its not working like on my local machine?

Please or to participate in this conversation.