Unverified Commit 83377610 authored by honfika's avatar honfika Committed by GitHub

Merge pull request #343 from justcoding121/develop

Include exception data when listener faield to start
parents 5c7f112d 18dafe56
......@@ -89,7 +89,6 @@ namespace Titanium.Web.Proxy.Examples.Basic
proxyServer.AddEndPoint(explicitEndPoint);
proxyServer.Start();
//Transparent endpoint is useful for reverse proxy (client is not aware of the existence of proxy)
//A transparent endpoint usually requires a network router port forwarding HTTP(S) packets or DNS
//to send data to this endPoint
......
......@@ -25,8 +25,7 @@ namespace Titanium.Web.Proxy.Models
Port = port;
EnableSsl = enableSsl;
}
/// <summary>
/// underlying TCP Listener object
/// </summary>
......@@ -53,7 +52,6 @@ namespace Titanium.Web.Proxy.Models
public bool IpV6Enabled => Equals(IpAddress, IPAddress.IPv6Any)
|| Equals(IpAddress, IPAddress.IPv6Loopback)
|| Equals(IpAddress, IPAddress.IPv6None);
}
/// <summary>
......
......@@ -646,11 +646,22 @@ namespace Titanium.Web.Proxy
private void Listen(ProxyEndPoint endPoint)
{
endPoint.Listener = new TcpListener(endPoint.IpAddress, endPoint.Port);
endPoint.Listener.Start();
try
{
endPoint.Listener.Start();
endPoint.Port = ((IPEndPoint)endPoint.Listener.LocalEndpoint).Port;
// accept clients asynchronously
endPoint.Listener.BeginAcceptTcpClient(OnAcceptConnection, endPoint);
endPoint.Port = ((IPEndPoint)endPoint.Listener.LocalEndpoint).Port;
// accept clients asynchronously
endPoint.Listener.BeginAcceptTcpClient(OnAcceptConnection, endPoint);
}
catch (SocketException ex)
{
var pex = new Exception($"Endpoint {endPoint} failed to start. Check inner exception and exception data for details.", ex);
pex.Data.Add("ipAddress", endPoint.IpAddress);
pex.Data.Add("port", endPoint.Port);
throw pex;
}
}
/// <summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment