Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Elasticsearch.Net.Connection
/// <summary>
/// IConnection implemented using <see cref="System.Net.Http.HttpClient"/>
/// </summary>
[Obsolete("The HttpClientConnection uses HttpClient and is not currently fully tested, with Elasticsearch.NET and NEST 2.0 we'll move the default HttpConnection over the HttpClient")]
public class HttpClientConnection : IConnection, IDisposable
{
private readonly IConnectionConfigurationValues _settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public class ConnectionConfiguration<T> : IConnectionConfigurationValues, IHideO
private TimeSpan? _maxRetryTimeout;
TimeSpan? IConnectionConfigurationValues.MaxRetryTimeout { get{ return _maxRetryTimeout; } }

private int? _keepAliveTime;
int? IConnectionConfigurationValues.KeepAliveTime { get{ return _keepAliveTime; } }

private int? _keepAliveInterval;
int? IConnectionConfigurationValues.KeepAliveInterval { get{ return _keepAliveInterval; } }

private string _proxyUsername;
string IConnectionConfigurationValues.ProxyUsername { get{ return _proxyUsername; } }

Expand Down Expand Up @@ -156,6 +162,13 @@ public ConnectionConfiguration(Uri uri = null)
//this.Port = uri.Port
}

public T EnableTcpKeepAlive(int keepAliveTime, int keepAliveInterval)
{
this._keepAliveTime = keepAliveTime;
this._keepAliveInterval = keepAliveInterval;
return (T) this;
}

public T MaximumRetries(int maxRetries)
{
this._maxRetries = maxRetries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,19 @@ public interface IConnectionConfigurationValues
/// Basic access authorization credentials to specify with all requests.
/// </summary>
/// TODO: Rename to BasicAuthenticationCredentials in 2.0
BasicAuthorizationCredentials BasicAuthorizationCredentials { get; }
BasicAuthorizationCredentials BasicAuthorizationCredentials { get; }

/// <summary>
/// KeepAliveTime - specifies the timeout, in milliseconds, with no
/// activity until the first keep-alive packet is sent.
/// </summary>
int? KeepAliveTime { get; }

/// <summary>
/// KeepAliveInterval - specifies the interval, in milliseconds, between
/// when successive keep-alive packets are sent if no acknowledgement is
/// received.
/// </summary>
int? KeepAliveInterval { get; }
}
}
5 changes: 5 additions & 0 deletions src/Elasticsearch.Net/Connection/HttpConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ protected virtual void AlterServicePoint(ServicePoint requestServicePoint)
requestServicePoint.UseNagleAlgorithm = false;
requestServicePoint.Expect100Continue = false;
requestServicePoint.ConnectionLimit = 10000;
//looking at http://referencesource.microsoft.com/#System/net/System/Net/ServicePoint.cs
//this method only sets internal values and wont actually cause timers and such to be reset
//So it should be idempotent if called with the same parameters
if (this.ConnectionSettings.KeepAliveTime.HasValue && this.ConnectionSettings.KeepAliveInterval.HasValue)
requestServicePoint.SetTcpKeepAlive(true, this.ConnectionSettings.KeepAliveTime.Value, this.ConnectionSettings.KeepAliveInterval.Value);
}

protected virtual HttpWebRequest CreateHttpWebRequest(Uri uri, string method, byte[] data, IRequestConfiguration requestSpecificConfig)
Expand Down