Framework: laravel + broadcasting + socket.io + redis with passport does not authenticate

Created on 30 Dec 2017  Â·  5Comments  Â·  Source: laravel/framework

  • Laravel Version: 5.5
  • PHP Version: 7.0

Description:

Erro 401 - laravel + broadcasting + socket.io + redis with passport

public channels function normally. For private channels, the error is:

âš  [04:53:17] - 4JvRYXBHYYCJCB1UAAAD could not be authenticated to private-notification.1 {"message":"Unauthenticated."} Client can not be authenticated, got HTTP status 401

I tried every possible possibility and I did not succeed!I'm desperate because I have time to deliver this functionality. Can someone help me? Why can not I authenticate private channels with passport?

Steps To Reproduce:

BroadcastServiceProvider.php

ublic function boot()
{

    Broadcast::routes(['middleware' => 'auth:api']);
    require base_path('routes/channels.php');
}

laravel-echo-server.json

{
    "authHost": "http://www.softshoplocal.com.br",
    "authEndpoint": "/broadcasting/auth",
    "clients": [
        {
            "appId": "9c93c4f229bb615f",
            "key": "6efe137de4101bc1b0429e6afd29e817"
        }
    ],
    "database": "redis",
    "databaseConfig": {
        "redis": {},
        "sqlite": {
            "databasePath": "/database/laravel-echo-server.sqlite"
        }
    },
    "devMode": true,
    "host": "www.softshoplocal.com.br",
    "port": "6001",
    "protocol": "http",
    "socketio": {},
    "sslCertPath": "",
    "sslKeyPath": "",
    "sslCertChainPath": "",
    "sslPassphrase": ""
}

channels.php

Broadcast::channel('notification.1', function ($user, $lojaId) {
    return true;
});

SendNotification.php

public function broadcastOn()
{
        //return new Channel('notification');
        return new PrivateChannel('notification.1');
}

my frontend (file vue)

Vue.use(VueEcho, {
    broadcaster: 'socket.io',
    host: 'localhost:6001',
    auth: {
        headers: {
            Authorization: 'Bearer' + sessionStorage.getItem("ss348978Token")
        },
    },
});

.....

this.$echo.private('notification.1').listen('SendNotification', (payload) => {
            this.mensagem.push(payload.data)
});

All 5 comments

This repo is for bug tracking. Use the forums or slack channel for solving your issue

I created the issues precisely because I believe this is a bug.

Can you tell if laravel supports broadcast authentication with passport?

Please use the forums for debugging your application. If you have a minimal case demonstrating a framework bug, please do of course feel free to open a fresh issue. :)

I've been trying to figure this out for over a week now.
published in every possible forum
And I met several people with the same problem.
But it's alright. I will not bother you anymore.

@renatosistemasvc yes, please advise me if there is any possible socketio solutions from laravel to js client side with out middle db storage.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shopblocks picture shopblocks  Â·  3Comments

SachinAgarwal1337 picture SachinAgarwal1337  Â·  3Comments

CupOfTea696 picture CupOfTea696  Â·  3Comments

PhiloNL picture PhiloNL  Â·  3Comments

YannPl picture YannPl  Â·  3Comments