-
Notifications
You must be signed in to change notification settings - Fork 658
difficulties getting multi-tenancy to work #23
Comments
Okay here's what might confuse you: When one of your apps (for example the demo) tries to connect to a private or presence channel on your WebSocket server, it sends an authentication signature. This signature gets generated by Laravel using the credentials in the You can completely ignore the But your apps / the websockets-demo application should still have this in the config: 'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'encrypted' => true,
'host' => 'socketmaster.dev',
'port' => 6001,
'scheme' => 'https',
'curl_options' => [
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
]
],
], |
Going to try it out and re-open the issue if I run into more problems. Thanks for the answer! |
HI @mpociot, following up.. I reset my socketmaster's broadcasting.php to its default settings (scheme http, no curl options) as you said I can completely ignore that one. My socketmaster's websockets.php config has the crt and key file pointed to and verify_peer set to false, and the apps added as mentioned in my first post On the demo's side. I added the correct values from the demo app inside the .env and the only modifications in the bootstrap.js are these two lines
Rebuilt the demo app.js and connected two users. Yay the chat works now, the socketmaster is handling it correctly it seems.. super Only problem left is when I try connecting to the socketmaster's debug dashboard and I connect to the demo app on port 6001. It allows me to connect and it populates the graph. But it doesn't show any events and in the terminal it prints this error
|
Hi @mpociot, continuing on with my attempt to set up multi-tenancy to have my socketmaster handle connections for the demo as well as existing apps that were using pusher.. I've run into more trouble. For this other application. I have a front-end built with vue-cli and a completely decoupled rest api built with Laravel. It was previously set up to work with Pusher to make use of presence channels (see who is online) and private channels (for notifications) on the vue-cli side, I've modified my echo connection from
to
it's not clear to me by the way what does the 'disableStats' do here. I thought stats are strictly enabled/disabled in the app configuration in websockets.php ok, rebuilt the app.. and then on the Laravel REST API end, I modified the .env values and modified the broadcasting.php config to
At first I left the host to 127.0.0.1 but since my privateChannel notifications weren't working I figured this needed to be changed to socketmaster.dev So with this configuration, my presence channels DO work.. however my private channel notifications don't work. Those are initiated from the server (I have a test endpoint that I visit and it is supposed to notify the specified user). The api endpoint looks like /admin/broadcast/user/{user}/message/{message} So I hit it with /admin/broadcast/user/1/message/test And it sends the message 'test' to user#1 provided he's connected. In the terminal, when I reload my front-end, it does show that my user is connected to both the presence channel and the private channel:
It does queue it up without error but the websockets:serve terminal never gets hit and nothing happens So the problem is my rest api is unable to broadcast back to the user via the socketmaster.dev As for the debug dashboard.. I have the same problem as above, I'm able to connect but get that Invalid Signature error and don't see any events. Any idea what I'm doing wrong please? |
@mpociot , @vesper8 did you manage to solve this issue? I have a same scenario where I have multiple decoupled apps that would connect to my socket server. As suggested above my My websockets.php in socket server
My bootstrap.js from a separate vuejs app
This connects and verifies user as expected by reading 'Auth-Token' from header, but also logs |
Ok so I'm trying to decouple the demo repository into two installations. And I'll also be using the "server-only" installation to work with all my other projects that currently use Pusher.
So I created a new mysql database 'db_socketmaster' and set it inside .env
I'm running this off Valet with --secure
In my websockets.php. I added the necessary entries to the SSL part as per the new Valet configuration.. no problem there
Then in the apps section I added this
Ignore the first 3, so the 4th one is for the laravel-websockets-demo. I used a random generator to generate all the fake app IDs and key/secrets
I set the broadcast driver to pusher (or in my case pusher-dev)
And then inside broadcasting.php config file, this is where I'm confused
I put this
I set another connection "pusher-dev" because on production I don't want to disable the host verification. I set the scheme to https for both.. and where I'm confused is.. what am I supposed to put for the key/secret/app_id ? since this is not for any particular app but is managing multiple apps
So I just commented out those values. Also I think the cluster is redundant at this point am I right?
I ran php artisan websockets:serve, no errors here
Then I modified the bootstrap.js inside the demo to this:
I'm using the "key" from the 4th app, the 'websocket-demo' app. And for the host I'm using my "socket manager" url, which is correct. I'm able to visit the debug dashboard at https://socketmaster.dev/laravel-websockets
I ran npm run prod
And then I visited the chat demo, logged in. I get no errors in the console or the network tab. But in my terminal running the websockets I get an 'Invalid Signature' error
I also gets CORS errors afterwards
Is this purely a CORS issue?
My 'allowed_origins' array is left empty on socketmaster's websockets.php configuration
The text was updated successfully, but these errors were encountered: