Laravel 5.3 / Redis / Socket.IO / Laravel-Echo private channels
See original GitHub issueHi,
I’ve been trying all weekend to get this working but after pulling alot of hair out i’ve stopped trying and going to ask here.
I’ve got a laravel project running in which i wish to have Redis with socket.io and laravel-echo working. I got this all working with public channels no problem at all. Now i wish to have it working with private channels aswell, here comes the fun part, I can’t get it to work.
After googling alot I still can’t seem to find THE solution to my problem. I’ll try to explain what I’ve got so far:
laravel-echo-server.json
{
"authHost": "http://192.168.10.10",
"authEndpoint": "/broadcasting/auth",
"clients": [
{
"appId": "***",
"key": "***"
}
],
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": true,
"host": "192.168.10.10",
"port": "6001",
"protocol": "http",
"socketio": {},
"sslCertPath": "",
"sslKeyPath": "",
"sslCertChainPath": "",
"sslPassphrase": ""
}
BroadcastServiceProvider.php boot method
public function boot()
{
Broadcast::routes();
Broadcast::channel('tenant_id.*', function ($user, $tenant_id) {
return true;
});
}
My event
class ProgressUpdated implements ShouldBroadcast
{
use SerializesModels;
public $tenantId;
public $data;
public function __construct($tenant_id)
{
$this->tenantId = $tenant_id;
$this->data = array(
'power'=> '10'
);
}
public function broadcastOn()
{
return ['tenant_id.' . $this->tenantId];
}
}
In the blade head:
<meta name="csrf-token" content="{{ csrf_token() }}">
In my Vue template (script part)
import Echo from "laravel-echo";
and in it’s ready
window.Echo = new Echo({
broadcaster: 'socket.io',
host: 'http://192.168.10.10:6001'
});
and inside an method that does an API call first to define what the tenant_id is:
var channelName = 'tenant_id.' + _this.integration.tenant_id;
window.Echo.private(channelName).listen('ProgressUpdated', (e) => {
console.log(e.data.power);
});
gulp runs fine, no issues there.
Whenever i got to the page to subscribe to the channel, laravel-echo-server returns the following messages: [11:36:56 AM] - BOpvHckeCQxfph8QAAAC could not be authenticated to private-tenant_id.1 Client can not be authenticated, got HTTP status 500
Could anyone please help me.
Thanks in advance. Kind regards, Pim Dröge
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
Closing this issue because it’s already solved, old or not relevant anymore. Feel free to reply if you’re still experiencing this issue.
I’ve been facing a similar issue which I’ve managed to fix.
I opened a PR upstream with my fix, hoping it’ll get accepted.
Try the change out, maybe it will work for you.