diff --git a/src/FastGateway/Tunnels/AgentClientConnection.cs b/src/FastGateway/Tunnels/AgentClientConnection.cs index 5d99df4..1b359dd 100644 --- a/src/FastGateway/Tunnels/AgentClientConnection.cs +++ b/src/FastGateway/Tunnels/AgentClientConnection.cs @@ -115,7 +115,8 @@ public sealed partial class AgentClientConnection : IAsyncDisposable switch (text) { case null: - break; + Log.LogClosed(_logger, ClientId); + return; case Ping: Log.LogRecvPing(_logger, ClientId); diff --git a/src/TunnelClient/Worker.cs b/src/TunnelClient/Worker.cs index bda43a4..44d4871 100644 --- a/src/TunnelClient/Worker.cs +++ b/src/TunnelClient/Worker.cs @@ -30,22 +30,21 @@ public class Worker : BackgroundService var serverClient = new ServerClient(monitorServer, tunnel, _services.GetRequiredService>()); - await monitorServer.RegisterNodeAsync(tunnel, stoppingToken); - while (!stoppingToken.IsCancellationRequested) { - await MonitorServerAsync(serverClient, tunnel, stoppingToken); + await MonitorServerAsync(monitorServer, serverClient, tunnel, stoppingToken); _logger.LogInformation("尝试重新连接到服务器..."); await Task.Delay(tunnel.ReconnectInterval, stoppingToken); _logger.LogInformation("重新连接到服务器中..."); } } - private async Task MonitorServerAsync(ServerClient serverClient, + private async Task MonitorServerAsync(MonitorServer monitorServer, ServerClient serverClient, Tunnel tunnel, CancellationToken stoppingToken) { try { + await monitorServer.RegisterNodeAsync(tunnel, stoppingToken); await serverClient.TransportCoreAsync(tunnel, stoppingToken); } catch (UnauthorizedAccessException e)