From d7a6144233bcae487877c3aa0e32980a9c10b815 Mon Sep 17 00:00:00 2001 From: Yannick Cholette Date: Fri, 17 Mar 2023 15:48:25 -0400 Subject: [PATCH 1/2] Don't log critical message when client disconnect --- src/JsonRpc/InputHandler.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/JsonRpc/InputHandler.cs b/src/JsonRpc/InputHandler.cs index 38f4d25c3..2a16adcbe 100644 --- a/src/JsonRpc/InputHandler.cs +++ b/src/JsonRpc/InputHandler.cs @@ -144,9 +144,17 @@ public void Start() { await ProcessInputStream(_stopProcessing.Token).ConfigureAwait(false); } + catch (IOException e) + { + if (e.InnerException is SocketException se && se.SocketErrorCode == SocketError.ConnectionReset) + _logger.LogInformation(e, "Connection reset by client."); + else + throw; + + } catch (Exception e) { - _logger.LogCritical(e, "unhandled exception"); + _logger.LogCritical(e, "Unhandled exception"); } } ).Subscribe(_inputActive) From 793e66d77c87185d4b9cc1fce1ab40b37cbb58b3 Mon Sep 17 00:00:00 2001 From: Joey Robichaud Date: Thu, 26 Oct 2023 10:54:25 -0700 Subject: [PATCH 2/2] Add missing using directive --- src/JsonRpc/InputHandler.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/JsonRpc/InputHandler.cs b/src/JsonRpc/InputHandler.cs index 2a16adcbe..cf733ebd0 100644 --- a/src/JsonRpc/InputHandler.cs +++ b/src/JsonRpc/InputHandler.cs @@ -4,6 +4,7 @@ using System.IO; using System.IO.Pipelines; using System.Linq; +using System.Net.Sockets; using System.Reactive; using System.Reactive.Concurrency; using System.Reactive.Disposables; @@ -145,16 +146,13 @@ public void Start() await ProcessInputStream(_stopProcessing.Token).ConfigureAwait(false); } catch (IOException e) + when (e.InnerException is SocketException { SocketErrorCode: SocketError.ConnectionReset }) { - if (e.InnerException is SocketException se && se.SocketErrorCode == SocketError.ConnectionReset) - _logger.LogInformation(e, "Connection reset by client."); - else - throw; - + _logger.LogInformation(e, "Connection reset by client."); } catch (Exception e) { - _logger.LogCritical(e, "Unhandled exception"); + _logger.LogCritical(e, "Unhandled exception."); } } ).Subscribe(_inputActive)