I'm using laravel echo server, and trying use the here, join and leave methods, on trying authenticate I received
Whoops, looks like something went wrong.
1/1
HttpException in Broadcaster.php line 65:
in Broadcaster.php line 65
at Broadcaster->verifyUserCanAccessChannel(object(Request), null) in RedisBroadcaster.php line 56
at RedisBroadcaster->auth(object(Request)) in BroadcastManager.php line 308
at BroadcastManager->__call('auth', array(object(Request))) in Facade.php line 221
at Facade::__callStatic('auth', array(object(Request))) in BroadcastController.php line 19
at BroadcastController->authenticate(object(Request))
at call_user_func_array(array(object(BroadcastController), 'authenticate'), array(object(Request))) in Controller.php line 55
at Controller->callAction('authenticate', array(object(Request))) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(BroadcastController), 'authenticate') in Route.php line 203
at Route->runController() in Route.php line 160
at Route->run() in Router.php line 559
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 561
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 520
at Router->dispatchToRoute(object(Request)) in Router.php line 498
at Router->dispatch(object(Request)) in Kernel.php line 174
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ValidatePostSize.php line 27
at ValidatePostSize->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 53
at require_once('/home/igor/projetos/echosuper/public/index.php') in server.php line 21
I write this in bootstrap.js
window.Echo.join('chat.1')
.here((users) => {
console.log(users)
})
.joining((user) => {
console.log(user.name);
})
.leaving((user) => {
console.log(user.name);
});
And rewrite the web route for
Route::get('/', function () {
$user = Auth::user();
if($user){
event(new \App\Events\PresenceUserEvent($user));
}
return view('welcome');
});
I created too the auth scaffold, trying authenticate an user, but without success
I discovered that using auth from laravel he work fine, but when I use laravel like api and vue like spa, vue do not authenticate on laravel and dispatch this error (on presence and on private channels), the question is: how to autheticate vue for using presence and private channels from echo like spa?
I'm using laravel 5.4, vue 2.2, laravel echo server and vue-echo.
I discovery that echo only works with session on browser, and not a spa because spa no has session.
@IgorDePaula Hey, I've been dealing with this error for quite some time now, the truth is this error is super duper vague. What it usually ends up being is an issue with authenticating the user. In most cases for me, it ended being that the cookies were not being sent to the laravel echo server. Please make sure that you're cookies exist for both the domain of your app, as well as the domain of the laravel echo server. Hit me up if you need help :smile:
thank you very much, have you any ideas?
@IgorDePaula You still technically do have a session, check which cookies it's sending to the server. If it doesn't include your session token, then you need to tell Laravel what your session domain is.
In my case, my echo server was running under a sub domain. My site was someapp.com and my echo server was at echo.someapp.com so I had to set my env SESSION_DOMAIN to be .someapp.com . The preceding dot is important as that signals all subdomains.
I have laravel on localhost:8000, echo localhost:6001 and vue spa on localhost:8080, all for tests. Sorry I no have any ideias for make that you said.
I find this tutorial, tomorrow I will try.
https://laravel.io/forum/10-09-2016-howto-broadcasting-laravel-echo-laravel-echo-server-and-jwt
the laravel echo server recognize the jwt token, validate it, dispatch the presence event, but the event not go to clientes
Were they successfully connected to the echo server?
yes. But now my problem is create a new plugin for vue, because I used vue-echo, but apper is incomplete, same things not working. I will create a new plugin injecting the "original" echo on vue.
Now I say, folow the doc of laravel, and the tutorial above.
@IgorDePaula Good luck bro
Thank you very much, @tbezman
@IgorDePaula did you find a solution for this problem?
@tnerbovik Check out what I wrote, this error is pretty broad, usually has to do with your cookies not being sent on the right domain. That's what it was in my case at least.
@tnerbovik yes, i found the solution: https://github.com/laravel/framework/issues/18437#issuecomment-288582469
as @tbezman mention, the problem come from the cookies. I checked and it's true.
I don't encourage applying the solution from https://laravel.io/forum/10-09-2016-howto-broadcasting-laravel-echo-laravel-echo-server-and-jwt.
It's not dynamic, or scalable.