laravel-swoole: Still getting the last authenticated user for every request. Something wrong with sandbox mode?
- Please provide your PHP and Swoole version. (
php -vandphp --ri swoole)
Swoole 2.1.3 on PHP 7.2.5
- Please provide your Laravel/Lumen version.
Laravel 5.6.20
- What did you do? If possible, provide a recipe for reproducing the error.
Log in to the application via Chrome. Ensure you are logged in. Open up another browser (f.e. Firefox) and visit the application’s URL. I am instantly logged in in the Firefox session.
- What did you expect to see?
Not being logged in in the Firefox session.
- What did you see instead?
Logged in in the Firefox session with the user I logged in with in the Chrome session.
I have enabled sandbox mode and running laravel-swoole behind nginx. For some reason, auth isn’t reset after each request. Any ideas?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 36 (15 by maintainers)
But I’d also like to express my thanks for developing this amazing plugin. My API became 3 times faster on average, without me having to do any changes whatsoever. As far as I’m concerned it’s basically magic. Thanks again!
Hi @lbadger ,
Try to add
Laravel\Passport\PassportServiceProvider::classto providers inconfig/swoole_http.php, not sure if it helps thought.And more details are needed to clarify your issue. You can refer to Issues-Guideline and Debug Guideline and open another issue.
my issue solved after updating config to
/* |-------------------------------------------------------------------------- | Instances here will be cleared on every request. |-------------------------------------------------------------------------- */ ‘instances’ => [ ‘auth’, ],
The fastest way I can help you is a laravel repo which can reproduce your bug. Welcome to open another issue if you find something new.
Thanks all for trying to debug this issue. I haven’t found the culprint yet. I will report back in a new issue if I find something useful.
Hi everryone,
I decide to close this issue first because:
Thanks a lot for all the comments in this issue, and some debug tips are collected to Debug Guideline.
So please open a new issue that it will be easier for a new discussion.
Hi @LostNCG ,
Thanks for your report. The behavior in websocket
connectmight be different from Laravel HTTP. The request passing toconnectevent callback is processed by my own implementaion. It’s implemented with pipeline as well though, but they are separate.Since getting an auth user depends on request and session by default in Laravel, however, there’s no request in these event callbacks. But you inspire me maybe I can design another API for getting an auth user in these event callbacks by sender’s socket id.
Anyway, thanks for your report, it helps!
This reproduce steps may as your reference:
websocket.php
Case 1: without clear auth instance in swoole_http.php
Result as expected when:
Unexpected result when:
Case 2: with clear auth instance in swoole_http.php
Result as expected when:
Unexpected result when:
But outcome slightly different with case 1
After set auth instance in config, everything work fine until I try to check user status in custom event “subscribe”.
Hope this report can help you in debug.
Hi @albertcht - I might have a look next week to see if I can make a copy of my (fairly big) app and throw everything out until I have a small reproduction of the problem. Hope it won’t take me too long…
Hi, since @deepakSP 's setup seems to work now, I will try your suggested setup and report back. Might be tomorrow though.