-
Notifications
You must be signed in to change notification settings - Fork 391
Auth error in laravel 5.8 with swoole 2.6 #371
Comments
@MostafaRabia can you share your swoole_http and swoole_websocket config files? /*
|--------------------------------------------------------------------------
| Providers here will be registered on every request.
|--------------------------------------------------------------------------
*/
'providers' => [
Illuminate\Auth\AuthServiceProvider::class,
App\Providers\AuthServiceProvider::class, |
|
websocket:
http:
|
@MostafaRabia you should add these lines:
To the Also you have misconfigured the And pls read this issue - #123 (comment) |
@MostafaRabia hmm ... Probably this is related to - #368 P.S did you try to call $request->user() ? |
@codercms when i send data to socket, $request switch to array with those inputs just. |
@MostafaRabia can you show how do you send data to socket? |
socket.emit('test',{ |
@MostafaRabia I mean the server side, not the client side |
$namespace = '\App\Http\Controllers\'; Websocket::on('connect',function($websocket,$request){ Websocket::on('MSGs',$namespace.'Messages\Send@Send'); public function Send($websocket,$request){...} |
@MostafaRabia actually you don't need to authenticate user manually, this work is delegated to the middleware layer:
Can you add logging to the onConnect handler?
|
Worked, got the user. |
@MostafaRabia nice, now you can write your application's business logic. |
@codercms |
@MostafaRabia If I understand you correctly, You wanna send some data back to the user? |
@MostafaRabia try this:
|
$request->user(); My request var is: not anything else, so i can't get user() |
@MostafaRabia now I see what you want to do.
|
@codercms that's come from the second: in websocket on connect it comes correctly. |
After you authenticated your user (in middleware):
I guess you have an older version as this is already merged into the default middleware. |
Make sure you read Issues Guideline and answer these questions before submitting your issue. Thanks!
(Any non-English issues will be closed immediately.)
Please provide your PHP and Swoole version. (
php -v
andphp --ri swoole
)PHP 7.2.24-0ubuntu0.18.04.2 (cli) (built: Jan 13 2020 18:39:59) ( NTS )
Version => 4.4.15
Please provide your Laravel/Lumen version.
Laravel: 5.8
Which release version of this package are you using?
2.6
What did you do? If possible, provide a recipe for reproducing the error.
What did you expect to see?
User function
What did you see instead?
NULL!
The text was updated successfully, but these errors were encountered: