我在Laravel Echo Server的私有通道上遇到错误。
laravel-echo-server.json
{
"authHost": "https://testapi.test.com",
"authEndpoint": "/api/broadcasting/auth",
"clients": [],
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": true,
"host": null,
"port": "6001",
"protocol": "https",
"socketio": {},
"secureOptions": 67108864,
"sslCertPath": "/etc/nginx/ssl/server.crt",
"sslKeyPath": "/etc/nginx/ssl/server.key",
"sslCertChainPath": "",
"sslPassphrase": "",
"subscribers": {
"http": true,
"redis": true
},
"apiOriginAllow": {
"allowCors": true,
"allowOrigin": "*",
"allowMethods": "GET, POST",
"allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
}
}
环境:
LARAVEL_ECHO_SERVER_AUTH_HOST=http://test.test
LARAVEL_ECHO_SERVER_SSL_CERT=""
LARAVEL_ECHO_SERVER_SSL_KEY=""
LARAVEL_ECHO_SERVER_PROTO=http
Chrome显示:
42["subscription_error", "private-user.5971", 500]
0: "subscription_error"
1: "private-user.5971"
2: 500
日志显示
[1:56:03 AM] - f4rbj7htL2hrRqQRAAAA could not be authenticated to private-user.5971
{
"message": "Class App\\Http\\Middleware\\Authenticate:api does not exist",
"exception": "ReflectionException",
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 718,
"trace": [
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 718,
"function": "__construct",
"class": "ReflectionClass",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php",
"line": 731,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"function": "Illuminate\\Support\\Traits\\{closure}",
"class": "Illuminate\\Support\\Collection",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Collections/Arr.php",
"line": 664,
"function": "array_filter"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Collections/Collection.php",
"line": 344,
"function": "where",
"class": "Illuminate\\Support\\Arr",
"type": "::"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php",
"line": 733,
"function": "filter",
"class": "Illuminate\\Support\\Collection",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 723,
"function": "reject",
"class": "Illuminate\\Support\\Collection",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 685,
"function": "gatherRouteMiddleware",,
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 669,
"function": "runRouteWithinStack",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 635,
"function": "runRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 624,
"function": "dispatchToRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 166,
"function": "dispatch",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 128,
"function": "Illuminate\\Foundation\\Http\\{closure}",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php",
"line": 67,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 167,
"function": "handle",
"class": "Barryvdh\\Debugbar\\Middleware\\InjectDebugbar",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/fideloper/proxy/src/TrustProxies.php",
"line": 57,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 167,
"function": "handle",
"class": "Fideloper\\Proxy\\TrustProxies",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
"line": 21,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
"line": 21,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php",
"line": 27,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php",
"line": 87,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance",
"type": "->"
},
{
"file": "/home/vagrant/myproject/app/Http/Middleware/Cors.php",
"line": 28,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 167,
"function": "handle",
"class": "App\\Http\\Middleware\\Cors",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 103,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 141,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/vagrant/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 110,
"function": "sendRequestThroughRouter",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "/home/vagrant/myproject/public/index.php",
"line": 52,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
}
]
}
Client can not be authenticated, got HTTP status 500
我不明白为什么私人渠道不起作用。然而,公共的是这样做的。任何帮助都是最好的!我最近确实从5.7升级到了Laravel 8,但后来又研究了另一个在8中的项目,它没有任何问题。
谢谢!
config/auth.php:
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session", "token"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
'hash' => false,
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| times out and the user is prompted to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => 10800,
];
发布于 2020-12-06 03:44:02
我必须在laravel-echo-server.json文件中更改下面这一行
"authEndpoint": "/api/broadcasting/auth",
至
"authEndpoint": "/broadcasting/auth",
https://stackoverflow.com/questions/65164096
复制相似问题