From 783e74d9c9fd212497c40a5f9678552d85c9512c Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Sat, 12 Jan 2019 22:25:55 +0100 Subject: [PATCH 1/2] Don't print stacktrace when failing to bind to 1900 --- RSSDP/SsdpCommunicationsServer.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/RSSDP/SsdpCommunicationsServer.cs b/RSSDP/SsdpCommunicationsServer.cs index e2e5c4e9f5..c64b6d02f3 100644 --- a/RSSDP/SsdpCommunicationsServer.cs +++ b/RSSDP/SsdpCommunicationsServer.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Net; using System.Net.Http; +using System.Net.Sockets; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -126,6 +126,10 @@ namespace Rssdp.Infrastructure { _BroadcastListenSocket = ListenForBroadcastsAsync(); } + catch (SocketException) + { + _logger.LogError("Failed to bind to port 1900. DLNA will be unavailable"); + } catch (Exception ex) { _logger.LogError(ex, "Error in BeginListeningForBroadcasts"); @@ -145,7 +149,7 @@ namespace Rssdp.Infrastructure { if (_BroadcastListenSocket != null) { - _logger.LogInformation("{0} disposing _BroadcastListenSocket.", GetType().Name); + _logger.LogInformation("{0} disposing _BroadcastListenSocket", GetType().Name); _BroadcastListenSocket.Dispose(); _BroadcastListenSocket = null; } From 81475e361b1665f895027feec9b4c0a4553f22dc Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Sun, 13 Jan 2019 01:30:43 +0100 Subject: [PATCH 2/2] Add exception message to log. Output will be something line: `Failed to bind to port 1900: Address already in use. DLNA will be unavailable` --- RSSDP/SsdpCommunicationsServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RSSDP/SsdpCommunicationsServer.cs b/RSSDP/SsdpCommunicationsServer.cs index c64b6d02f3..2255ef35ab 100644 --- a/RSSDP/SsdpCommunicationsServer.cs +++ b/RSSDP/SsdpCommunicationsServer.cs @@ -126,9 +126,9 @@ namespace Rssdp.Infrastructure { _BroadcastListenSocket = ListenForBroadcastsAsync(); } - catch (SocketException) + catch (SocketException ex) { - _logger.LogError("Failed to bind to port 1900. DLNA will be unavailable"); + _logger.LogError("Failed to bind to port 1900: {Message}. DLNA will be unavailable", ex.Message); } catch (Exception ex) {