Closed dysTOS closed 5 months ago
Hi @dysTOS, what does your Nginx (or equivalent) configuration look like?
Thanks for your reply @joedixon ! I was able to get this partially solved in the meanwhile.
I have upgraded laravel/framework to 11.0.8 and did some changes to my webserver-configuration and .env variables, but went back to settings i already had before in the end, so unfortunately I am not sure what solved this issue exactly.
Here are my current configurations and relevant settings:
Backend: api.example.com (running in a Plesk Environment with Apache + Nginx as reverse proxy) Frontend: app.example.com (Angular SPA)
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';
// invoked on init
(window as any).Pusher = Pusher;
this._echo = new Echo({
broadcaster: 'reverb',
key: 'appkey',
wsHost: 'api.example.com',
wsPort: 443,
wssPort: 443,
forceTLS: true,
enabledTransports: ['ws', 'wss'],
authorizer: (channel, options) => {
return {
authorize: (socketId, callback) => {
firstValueFrom(
this.httpClient.post('https://api.example.com/api/broadcasting/auth', {
socket_id: socketId,
channel_name: channel.name,
})
)
.then((response) => {
callback(false, response);
})
.catch((error) => {
callback(true, error);
});
},
};
},
});
// invoked after ws-connection is established to subscribe to the private-channel
this._echo.private('App.Models.User.' + this.myUserService.getUserId()).notification((e) => {
doMyStuff(e);
});
APP_NAME=test
APP_ENV=production
APP_KEY=key
APP_DEBUG=true
APP_URL=https://api.example.com
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=production
BROADCAST_DRIVER=pusher
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=database
SESSION_DRIVER=file
SESSION_LIFETIME=120
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
REVERB_APP_ID='id'
REVERB_APP_KEY='key'
REVERB_APP_SECRET='secret'
REVERB_HOST=api.example.com
REVERB_PORT=8080
REVERB_SCHEME=http
#NOT NEEDED AS FRONTEND IS SEPERATE APP
#VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
#VITE_REVERB_HOST=api.example.com
#VITE_REVERB_PORT=80
#VITE_REVERB_SCHEME=http
Broadcast::channel('App.Models.User.{userId}', function ($user, $userId) {
return $user->id == $userId;
});
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// needed this because I use laravel/sanctum for authentication
Broadcast::routes(['prefix' => 'api', 'middleware' => ['auth:sanctum']]);
require base_path('routes/channels.php');
}
}
location /app/ {
proxy_pass http://0.0.0.0:8080;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
Tried also with additional 'location /apps/', 'location /ws/', 'location /wss/' and same content, but it seems that /app/ is sufficient.
BUT there is still one issue - from 10 sent notifications only an average of 2 to 3 messages are received by my frontend - found no log-entries or failed jobs.
@joedixon please forget my last sentence - EVERY message is sent but it took up to 10 minutes until the last message was received by my frontend application. I will have a look on this and open a new issue if needed. Have a nice day! :-)
Reverb Version
1.x
Laravel Version
11.0.7
PHP Version
8.2
Description
First, I already have a fully working reverb websocket connection when developing locally - Private-Channels, Authentication, Notifications, SSL - everything works like a charm. My frontend is a seperate angular-application running on a different subdomain.
On my production server the websocket connection is also established as it should be. BUT when firing a notification that should be broadcasted via reverb, the queued job fails with the following error:
I already thought of a problem in the .env file - but I could not find a solution so far...
Steps To Reproduce
sorry for missing out that