I can’t get Laravel Reverb to work for me on my server with cyberpanel.
I have configured everything well, when I test my application from local pointing without SSL(WS) I can connect and so far so good, but when I uploaded it to keep it in production is where I find the problem:
WebSocket connection to'wss://domain.com/app/sdfsdsdf323?protocol=7&client=js&version=8.4.0-rc2&flash=false' failed:
I have tried many things from setting up reverse proxy and I get nothing, I can’t get it to work.
Has anyone here configured Laravel Reverb in Cyberpanel?
Here are my configurations.
Laravel .env
REVERB_APP_ID=123456
REVERB_APP_KEY=sdfsdsdf323
REVERB_APP_SECRET=sdfsdsdf323
REVERB_SERVER_HOST="127.0.0.1"
REVERB_SERVER_PORT=8080
REVERB_HOST="domain.com"
REVERB_PORT=443
REVERB_SCHEME=http
REVERB_LOCAL_CERT="/etc/letsencrypt/live/domain.com/cert.pem"
#REVERB_LOCAL_PK="/etc/letsencrypt/live/domain.com/privkey.pem"
React .env
REACT_APP_REVERB_APP_KEY=sdfsdsdf323
REACT_APP_REVERB_HOST=domain.com
REACT_APP_REVERB_PORT=443
REACT_APP_REVERB_SCHEME=https
REACT_APP_REVERB_PATH="/ws"
Laravel Echo configuration
window.Pusher = Pusher;
window.Echo = new Echo({
broadcaster: 'reverb',
key: process.env.REACT_APP_REVERB_APP_KEY,
wsHost: process.env.REACT_APP_REVERB_HOST,
wsPort: process.env.REACT_APP_REVERB_PORT ?? 8080,
wssPort: process.env.REACT_APP_REVERB_PORT ?? 443,
//wsPath: process.env.REACT_APP_REVERB_PATH ?? "/",
forceTLS: (process.env.REACT_APP_REVERB_SCHEME ?? 'https') === 'https',
enabledTransports: ['ws','wss'],
authorizer: (channel, options) => {
return {
authorize: (socketId, callback) => {
axios.post('/api/broadcasting/auth', {
socket_id: socketId,
channel_name: channel.name
})
.then(response => {
callback(null, response.data);
})
.catch(error => {
callback(error);
});
}
};
},
});
The application works fine when it is local. I have the websocket server on a VPS with cyberpanel and then run the React app locally, The application works fine when it is local as I mentioned, but when I deploy it to production on a hosting is when it gives the problem that does not connect, I read that it is a certificate issue but try to configure it and then I got no luck.
Some other discussions I was consulting but I tried to do everything they said and got no luck at all.
https://github.com/laravel/reverb/issues/107
https://github.com/laravel/framework/discussions/50675