I'm using laravel-echo with redis driver to broadcast notifications. It works perfectly on my local system. But on my server, I'm getting ERR_CONNECTION_TIMED_OUT
error. Browser console displays http://ex.example.com:6001/socket.io/socket.io.js net::ERR_CONNECTION_TIMED_OUT
.
I have not any knowledge about socket and redis. So I just have followed instruction of laravel official doc and laravel-echo-server. and made just one change from here. But with help of that change, I'm able to let execute remaining js script. Issue of socket.io.js is still unsolved (Also in github).
Here is steps which I have followed.
js
import Echo from "laravel-echo"
window.io = require('socket.io-client'); //suggested in github issue
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ':6001'
});
laravel-echo-server.json
{
"authHost": "http://ex.example.com",
"authEndpoint": "/broadcasting/auth",
"clients": [
{
"appId": "edbf10287972d875",
"key": "96403c9f93e1a2d86185e2d21aa0fae1"
}
],
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": true,
"host": null,
"port": "6001",
"protocol": "http",
"socketio": {},
"sslCertPath": "",
"sslKeyPath": ""
}
If anyone knows the solution, it will be appreciated.
This may sound simple, but did you check the firewall settings on your server?
edit: thanks to @AkshayVaghasiya for sharing the instructions for setting up your firewall correctly [read here].