I've implemented broadcasting functionality using driver redis and laravel-echo-server.
Everything is working fine events are working fine too, but the problem is, after some span of time, 3 hours or 6 hours (time is not fixed) , it disconnects automatically even laravel-echo-server is running in the background.
But if I refresh the page everything starts working fine again. I've tries many ways but I could not figure out what is the problem.
My project will run on localhost forever.
File .env
BROADCAST_DRIVER=redis
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
LARAVEL_ECHO_PORT=6001
laravel-echo-server.js
{
"authHost": "http://localhost",
"authEndpoint": "/broadcasting/auth",
"clients": [],
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": false,
"host": null,
"port": "6001",
"protocol": "http",
"socketio": {},
"secureOptions": 67108864,
"sslCertPath": "",
"sslKeyPath": "",
"sslCertChainPath": "",
"sslPassphrase": "",
"subscribers": {
"http": true,
"redis": true
},
"apiOriginAllow": {
"allowCors": false,
"allowOrigin": "",
"allowMethods": "",
"allowHeaders": ""
}
}
laravel-echo-setup.js
import Echo from 'laravel-echo';
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ":" + window.laravel_echo_port,
enabledTransports: ['ws', 'wss'],
disableStats: true,
forceTLS: false,
transports: ['websocket', 'polling', 'flashsocket']
});