fix: 增强后端Socket连接诊断日志
- connection事件记录远程IP/传输方式/是否携带auth token - Web客户端注册记录请求来源IP,便于排查连接问题
This commit is contained in:
@@ -1171,7 +1171,10 @@ class RemoteControlServer {
|
||||
|
||||
private setupSocketHandlers(): void {
|
||||
this.io.on('connection', (socket: any) => {
|
||||
this.logger.info(`新连接建立: ${socket.id} (传输: ${socket.conn.transport.name})`)
|
||||
const remoteAddr = socket.handshake?.address || 'unknown'
|
||||
const transport = socket.conn?.transport?.name || 'unknown'
|
||||
const hasAuth = !!socket.handshake?.auth?.token
|
||||
this.logger.info(`[Conn] New connection: ${socket.id} (transport: ${transport}, ip: ${remoteAddr}, hasAuth: ${hasAuth})`)
|
||||
|
||||
// 🔧 移除强制认证检查 - 让设备端可以正常连接,认证只在web客户端注册时进行
|
||||
// 🔧 增强连接监控,帮助诊断误断开问题
|
||||
@@ -1661,7 +1664,9 @@ class RemoteControlServer {
|
||||
*/
|
||||
private handleWebClientRegister(socket: any, data: any): void {
|
||||
try {
|
||||
// 🔐 Web客户端认证验证:检查认证token
|
||||
this.logger.info(`[WebClient] Register request from ${socket.id} (ip: ${socket.handshake?.address || 'unknown'})`)
|
||||
|
||||
// Web client auth: check token
|
||||
const token = socket.handshake.auth?.token
|
||||
if (!token) {
|
||||
this.logger.warn(`🔐 Web客户端注册缺少认证token: ${socket.id}`)
|
||||
|
||||
Reference in New Issue
Block a user