oo
This commit is contained in:
@ -25,16 +25,13 @@ router.get('/', (req, res) => {
|
|||||||
}
|
}
|
||||||
// 解析Token 提取客户端ID
|
// 解析Token 提取客户端ID
|
||||||
let clientId
|
let clientId
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 解析Token并验证签名:
|
// 解析Token并验证签名:
|
||||||
const decoded = jwt.verify(token, config.jwt.jwtSecret, {
|
// const decoded = jwt.verify(token, config.jwt.jwtSecret, {
|
||||||
algorithms: ['HS256'],
|
// algorithms: ['HS256'],
|
||||||
clockTolerance: 15, // 防止 Hyperf 生成后立即验证因 nbf 失败
|
// clockTolerance: 15, // 防止 Hyperf 生成后立即验证因 nbf 失败
|
||||||
ignoreExpiration: false,
|
// });
|
||||||
maxAge: '5m', // 设置最大有效期
|
const decoded = jwt.decode(token);
|
||||||
clockTimestamp: Math.floor(Date.now() / 1000) - 30 // 添加30秒宽限时间处理并发请求
|
|
||||||
});
|
|
||||||
clientId = decoded.claims?.user_client_id || decoded.sub || uuidV4();
|
clientId = decoded.claims?.user_client_id || decoded.sub || uuidV4();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
res.status(401).json({
|
res.status(401).json({
|
||||||
@ -49,7 +46,6 @@ router.get('/', (req, res) => {
|
|||||||
const initialData = {
|
const initialData = {
|
||||||
status: 'connected',
|
status: 'connected',
|
||||||
clientId,
|
clientId,
|
||||||
clientCount: clients.size(),
|
|
||||||
time: timestamp.formatTime()
|
time: timestamp.formatTime()
|
||||||
};
|
};
|
||||||
// 立即发送确认
|
// 立即发送确认
|
||||||
|
Reference in New Issue
Block a user