aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2019-12-26 20:57:46 +0100
committerBond_009 <bond.009@outlook.com>2020-01-13 20:06:08 +0100
commit5ca68f9623e414b85ddbda1f97895f1b90bd05e0 (patch)
tree8360af78a08b0b84b2a4854e35df1ab5e55f6c80 /Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
parent976459d3e8a8b889cebc2cf281e38b0fbc19c9b9 (diff)
Fix nullref exception and added logging
Diffstat (limited to 'Emby.Server.Implementations/HttpServer/HttpListenerHost.cs')
-rw-r--r--Emby.Server.Implementations/HttpServer/HttpListenerHost.cs17
1 files changed, 8 insertions, 9 deletions
diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
index 4baf96ab5..ebae4d0b1 100644
--- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
+++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
@@ -518,30 +518,29 @@ namespace Emby.Server.Implementations.HttpServer
return;
}
- var url = context.Request.GetDisplayUrl();
- _logger.LogInformation("WS {Url}. UserAgent: {UserAgent}", url, context.Request.Headers[HeaderNames.UserAgent].ToString());
-
try
{
- var webSocket = await context.WebSockets.AcceptWebSocketAsync(null).ConfigureAwait(false);
+ _logger.LogInformation("WS Request from {IP}", context.Connection.RemoteIpAddress);
+
+ WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync().ConfigureAwait(false);
var connection = new WebSocketConnection(
_loggerFactory.CreateLogger<WebSocketConnection>(),
webSocket,
- context.Connection.RemoteIpAddress)
+ context.Connection.RemoteIpAddress,
+ context.Request.Query)
{
- Url = url,
- QueryString = context.Request.Query,
OnReceive = ProcessWebSocketMessageReceived
};
WebSocketConnected?.Invoke(this, new GenericEventArgs<IWebSocketConnection>(connection));
await connection.ProcessAsync().ConfigureAwait(false);
+ _logger.LogInformation("WS closed from {IP}", context.Connection.RemoteIpAddress);
}
- catch (WebSocketException ex)
+ catch (Exception ex) // Otherwise ASP.Net will ignore the exception
{
- _logger.LogError(ex, "ProcessWebSocketRequest error");
+ _logger.LogError(ex, "WebSocketRequestHandler error");
if (!context.Response.HasStarted)
{
context.Response.StatusCode = 500;