Commit 5acb2ff4 authored by justcoding121's avatar justcoding121

update linger time default to 30 seconds

parent ae7ef96b
...@@ -276,7 +276,8 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -276,7 +276,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
LingerState = new LingerOption(true, proxyServer.TcpTimeWaitSeconds) LingerState = new LingerOption(true, proxyServer.TcpTimeWaitSeconds)
}; };
if(proxyServer.ReuseSocket) //linux has a bug with socket reuse in .net core.
if (proxyServer.ReuseSocket && !RunTime.IsLinux)
{ {
tcpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); tcpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
} }
......
...@@ -109,12 +109,6 @@ namespace Titanium.Web.Proxy ...@@ -109,12 +109,6 @@ namespace Titanium.Web.Proxy
systemProxySettingsManager = new SystemProxyManager(); systemProxySettingsManager = new SystemProxyManager();
} }
//linux have bug with socket reuse
if (!RunTime.IsLinux)
{
ReuseSocket = true;
}
CertificateManager = new CertificateManager(rootCertificateName, rootCertificateIssuerName, CertificateManager = new CertificateManager(rootCertificateName, rootCertificateIssuerName,
userTrustRootCertificate, machineTrustRootCertificate, trustRootCertificateAsAdmin, ExceptionFunc); userTrustRootCertificate, machineTrustRootCertificate, trustRootCertificateAsAdmin, ExceptionFunc);
} }
...@@ -184,7 +178,6 @@ namespace Titanium.Web.Proxy ...@@ -184,7 +178,6 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
public int ConnectionTimeOutSeconds { get; set; } public int ConnectionTimeOutSeconds { get; set; }
/// <summary> /// <summary>
/// Maximum number of concurrent connections per remote host in cache. /// Maximum number of concurrent connections per remote host in cache.
/// Only valid when connection pooling is enabled. /// Only valid when connection pooling is enabled.
...@@ -194,15 +187,15 @@ namespace Titanium.Web.Proxy ...@@ -194,15 +187,15 @@ namespace Titanium.Web.Proxy
/// <summary> /// <summary>
/// Number of seconds to linger when Tcp connection is in TIME_WAIT state. /// Number of seconds to linger when Tcp connection is in TIME_WAIT state.
/// Default value is 3. /// Default value is 30.
/// </summary> /// </summary>
public int TcpTimeWaitSeconds { get; set; } = 3; public int TcpTimeWaitSeconds { get; set; } = 30;
/// <summary> /// <summary>
/// Should we resues client/server tcp sockets. /// Should we reuse client/server tcp sockets.
/// Default is true (false for linux due to bug in .Net core). /// Default is true (false for linux due to bug in .Net core).
/// </summary> /// </summary>
public bool ReuseSocket { get; set; } public bool ReuseSocket { get; set; } = true;
/// <summary> /// <summary>
/// Total number of active client connections. /// Total number of active client connections.
...@@ -300,20 +293,6 @@ namespace Titanium.Web.Proxy ...@@ -300,20 +293,6 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
public IEnumerable<string> ProxyAuthenticationSchemes { get; set; } = new string[0]; public IEnumerable<string> ProxyAuthenticationSchemes { get; set; } = new string[0];
/// <summary>
/// Dispose the Proxy instance.
/// </summary>
public void Dispose()
{
if (ProxyRunning)
{
Stop();
}
CertificateManager?.Dispose();
BufferPool?.Dispose();
}
/// <summary> /// <summary>
/// Event occurs when client connection count changed. /// Event occurs when client connection count changed.
/// </summary> /// </summary>
...@@ -638,7 +617,8 @@ namespace Titanium.Web.Proxy ...@@ -638,7 +617,8 @@ namespace Titanium.Web.Proxy
{ {
endPoint.Listener = new TcpListener(endPoint.IpAddress, endPoint.Port); endPoint.Listener = new TcpListener(endPoint.IpAddress, endPoint.Port);
if (ReuseSocket) //linux has a bug with socket reuse in .net core.
if (ReuseSocket && !RunTime.IsLinux)
{ {
endPoint.Listener.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); endPoint.Listener.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
} }
...@@ -849,5 +829,19 @@ namespace Titanium.Web.Proxy ...@@ -849,5 +829,19 @@ namespace Titanium.Web.Proxy
{ {
return new RetryPolicy<T>(retries, tcpConnectionFactory); return new RetryPolicy<T>(retries, tcpConnectionFactory);
} }
/// <summary>
/// Dispose the Proxy instance.
/// </summary>
public void Dispose()
{
if (ProxyRunning)
{
Stop();
}
CertificateManager?.Dispose();
BufferPool?.Dispose();
}
} }
} }
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