- Did you set the same key, secret and id in soketi?
- What queue driver are you using? If redis or similar, make sure that the queue listener is running
Broadcast not received in the browser
I setup a soketi server on 127.0.0.1:6001, it's running and if I go to 127.0.0.1:6001 I see the OK text in the browser.
This is my Laravel configuration:
.env:
BROADCAST_DRIVER=pusher
QUEUE_CONNECTION=sync
PUSHER_APP_ID=mypusherid
PUSHER_APP_KEY=mypusherkey
PUSHER_APP_SECRET=mypushersecret
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
SOKETI_DEBUG=1
bootstrap.js:
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
cluster: process.env.MIX_PUSHER_APP_CLUSTER,
forceTLS: false
});
app.js:
require('./bootstrap');
Echo.channel('status_update_channel')
.listen('OrderShipmentStatusUpdated', (e) => {
console.log("broadcast received");
});
broadcasting.php:
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'host' => env('PUSHER_HOST', '127.0.0.1'),
'port' => env('PUSHER_PORT', 6001),
'scheme' => env('PUSHER_SCHEME', 'http'),
'encrypted' => false,
'useTLS' => false,
],
],
app.php:
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Broadcasting\BroadcastServiceProvider::class,
// ...
homepage.blade.php: (At the bottom of the body)
<script src="{{ asset('js/app.js') }}"></script>
OrderShipmentStatusUpdated.php event:
class OrderShipmentStatusUpdated implements ShouldBroadcastNow
{
// ...
public function broadcastOn()
{
Log::debug("Broadcast sent");
return new Channel('status_update_channel');
}
When I go to Tinker and type OrderShipmentStatusUpdated::dispatch();, nothing shows up in the browser. and the Tinker output is:
>>> OrderShipmentStatusUpdated::dispatch();
=> []
**There are no JavaScript errors in the browser
How can I debug it to find the reason?
@Ligonsker seems you aren't using the defaults I suggested? You have two options
- use the defaults in env
- change the values in soketi using environment variables (not env file), or a config file in json
I recommend the first in dev
Soketi has nothing to do with laravel, so it does not read your env file:)
Please or to participate in this conversation.