question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Laravel 5.3 / Redis / Socket.IO / Laravel-Echo private channels

See original GitHub issue

Hi,

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:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
driesvintscommented, Oct 30, 2018

Closing this issue because it’s already solved, old or not relevant anymore. Feel free to reply if you’re still experiencing this issue.

0reactions
darryntencommented, Nov 24, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Laravel 5.3 / Redis / Socket.IO / Laravel-Echo private channels
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...
Read more >
laravel echo with redis and socket io - php - Stack Overflow
I had a lot of troubles trying to set up my websocket connection, but a finally figured it out and my code looks...
Read more >
Laravel Echo, Socket.io + Redis Setup - Laracasts
My project was a 5.2 app with socket.io and redis running manually. This all worked fine. Now I upgraded to 5.3 to use...
Read more >
Broadcasting - Laravel - The PHP Framework For Web Artisans
The laravel-websockets package is a pure PHP, Pusher compatible WebSocket ... so we will broadcast the event on a private channel that is...
Read more >
Event Broadcasting (Laravel 5.3)
Installing Laravel Echo; Listening For Events; Leaving A Channel; Namespaces ... Socket.IO. If you are going to pair the Redis broadcaster with a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found