This repository was archived by the owner on Mar 24, 2025. It is now read-only.
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
laravel swoole websocket auth problem with socket.io-client v3 #498
Open
Description
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
) - Please provide your Laravel/Lumen version.
- Which release version of this package are you using?
Software | Version |
---|---|
PHP | 8.0.8 |
Swoole | 4.7.0 |
Laravel | 8.51.0 |
laravel-swoole | 2.8 |
- What did you do? If possible, provide a recipe for reproducing the error.
config/swoole_http.php
'providers' => [
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Auth\AuthServiceProvider::class,
\App\Providers\AuthServiceProvider::class,
],
config/swoole_websocket.php
'middleware' => [
SwooleTW\Http\Websocket\Middleware\DecryptCookies::class,
SwooleTW\Http\Websocket\Middleware\StartSession::class,
SwooleTW\Http\Websocket\Middleware\Authenticate::class,
],
Socket.io-Client v3
this.socket = io('http://localhost:80',
{
transports: ['websocket'],
withCredentials: true,
}
);
routes/websocket.php
Websocket::on('connect', function ($websocket, $request) {
var_dump("Trying to Access Authenticated User!");
$user = $request->user();
var_dump( $user );
var_dump( auth()->user() );
}
I am also using Laravel Sanctum.
-
What did you expect to see?
The authenticated user object -
What did you see instead?
Null
How can i achieve, getting the correct user?
Metadata
Metadata
Assignees
Labels
No labels