diff --git a/global.json b/global.json index 0f11ff6..112677b 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "7.0.203" + "version": "7.0.306" } } \ No newline at end of file diff --git a/src/JT808.Gateway/JT808TcpServer.cs b/src/JT808.Gateway/JT808TcpServer.cs index b6cea50..31973ee 100644 --- a/src/JT808.Gateway/JT808TcpServer.cs +++ b/src/JT808.Gateway/JT808TcpServer.cs @@ -120,6 +120,11 @@ await Task.Factory.StartNew(async (state) => } catch (OperationCanceledException) { + break; + } + catch (ObjectDisposedException) + { + break; } catch (Exception) { @@ -310,8 +315,13 @@ public Task StopAsync(CancellationToken cancellationToken) { Logger.LogInformation("JT808 Tcp Server Stop"); if (server?.Connected ?? false) - server.Shutdown(SocketShutdown.Both); + server.Shutdown(SocketShutdown.Receive); server?.Close(); + server?.Dispose(); + foreach (var item in SessionManager.Sessions) + { + item.Value.Client.Close(); + } return Task.CompletedTask; } }