i am trying to create online chat and first i try to get online users . i used predis ,laravel echo ,yarn ,socket.io-client and laravel-echo-server. and this my app.js code :
require('./bootstrap');
import Echo from "laravel-echo"
window.io = require('socket.io-client');
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ':6001'
});
console.log("ok ");
window.Echo.join('online')
.here((users) => {
console.log('ok here');
})
.joining((user) => {
console.log(user.name);
})
.leaving((user) => {
console.log(user.name);
});
my channel :
Broadcast::channel('online', function ($user) {
return $user;
});
after run my browser : here
laravel echo server : here
i added App\Providers\BroadcastServiceProvider::class,
in
config/app.php and change .env BROADCAST_DRIVER=redis
It looks like your echo server is trying to auth against http://localhost
when your Laravel app is on http://localhost:8000
You probably want to set the authHost
config to http://localhost:8000
in your laravel-echo-server.json
config file