fixes #526 - Make server startup error message friendlier

This commit is contained in:
Luke Pulverenti 2013-09-13 11:02:40 -04:00
parent ef6c513ede
commit 1591558fc0
3 changed files with 21 additions and 4 deletions

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common;
using System.Net.Sockets;
using MediaBrowser.Common;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
@ -169,6 +170,12 @@ namespace MediaBrowser.Server.Implementations.ServerManager
HttpServer.EnableHttpRequestLogging = ConfigurationManager.Configuration.EnableHttpLevelLogging;
HttpServer.Start(_applicationHost.HttpServerUrlPrefix);
}
catch (SocketException ex)
{
_logger.ErrorException("The http server is unable to start due to a Socket error. This can occasionally happen when the operating system takes longer than usual to release the IP bindings from the previous session. This can take up to five minutes. Please try waiting or rebooting the system.", ex);
throw;
}
catch (HttpListenerException ex)
{
_logger.ErrorException("Error starting Http Server", ex);

View File

@ -4,6 +4,7 @@ using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging;
using System;
using System.Net;
using System.Net.Sockets;
namespace MediaBrowser.Server.Implementations.WebSocket
{
@ -60,7 +61,16 @@ namespace MediaBrowser.Server.Implementations.WebSocket
TimeOut = TimeSpan.FromHours(12)
};
WebSocketServer.Start();
try
{
WebSocketServer.Start();
}
catch (SocketException ex)
{
_logger.ErrorException("The web socket server is unable to start on port {0} due to a Socket error. This can occasionally happen when the operating system takes longer than usual to release the IP bindings from the previous session. This can take up to five minutes. Please try waiting or rebooting the system.", ex, portNumber);
throw;
}
Port = portNumber;

View File

@ -1,5 +1,4 @@
using System.Threading;
using MediaBrowser.Api;
using MediaBrowser.Api;
using MediaBrowser.Common;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Constants;
@ -57,6 +56,7 @@ using System.Net;
using System.Net.Cache;
using System.Net.Http;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.ServerApplication