Skip to content

Commit

Permalink
websocket连接日志增加连接端口
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Aug 11, 2024
1 parent 71accb5 commit 068132d
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ protected virtual async Task HandleNotify(WebSocket socket, String token)

var ip = UserHost;
var sid = Rand.Next();
WriteLog("WebSocket连接", true, $"State={socket.State} sid={sid}");
var connection = HttpContext.Connection;
var remote = new IPEndPoint(connection.RemoteIpAddress, connection.RemotePort);
WriteLog("WebSocket连接", true, $"State={socket.State} sid={sid} Remote={remote}");

// 长连接上线
_deviceService.SetOnline(device, true, token, ip);
Expand All @@ -229,7 +231,7 @@ await socket.WaitForClose(txt =>
}
}, source);

WriteLog("WebSocket断开", true, $"State={socket.State} CloseStatus={socket.CloseStatus} sid={sid}");
WriteLog("WebSocket断开", true, $"State={socket.State} CloseStatus={socket.CloseStatus} sid={sid} Remote={remote}");

// 长连接下线
_deviceService.SetOnline(device, false, token, ip);
Expand Down

0 comments on commit 068132d

Please sign in to comment.