Skip to content

Using connection pools throws SocketException #802

Closed
@ryanvanderpol

Description

@ryanvanderpol

I'm upgrading an app from an older version of NEST to 1.0.0-rc1. One of the newer features I'm trying to use is connection pools. However, whenever I create a new client using either the StaticConnectionPool or the SniffingConnectionPool almost all actions against the client end up throwing a SocketException. Here is my initialization code:

var connectionPool = new StaticConnectionPool(new List<Uri>() {"<url.from.config>", "<url.from.config>"});
var settings = new ConnectionSettings(connectionPool, defaultIndex: "myindex");

var client = new ElasticClient(settings);

Later on I go and do the following:

client.CreateIndex("test");

And I get a SocketException. There appear to be a variety of error messages. Here are some of the common ones:

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

An operation was attempted on something that is not a socket

The system detected an invalid pointer address in attempting to use a pointer argument in a call

Here is a stack trace:

System.dll!System.Net.Sockets.Socket.Receive(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags) + 0x61 bytes  
System.dll!System.Net.Sockets.NetworkStream.Read(byte[] buffer, int offset, int size) + 0x83 bytes  
System.dll!System.Net.PooledStream.Read(byte[] buffer, int offset, int size) + 0x14 bytes   
System.dll!System.Net.Connection.SyncRead(System.Net.HttpWebRequest request, bool userRetrievedStream, bool probeRead) + 0xfc bytes 
System.dll!System.Net.ConnectStream.ProcessWriteCallDone(System.Net.ConnectionReturnResult returnResult) + 0x89 bytes   
System.dll!System.Net.HttpWebRequest.WriteCallDone(System.Net.ConnectStream stream, System.Net.ConnectionReturnResult returnResult) + 0xbb bytes    
System.dll!System.Net.ConnectStream.CallDone(System.Net.ConnectionReturnResult returnResult) + 0x63 bytes   
System.dll!System.Net.ConnectStream.CloseInternal(bool internalCall, bool aborting) + 0xde bytes    
System.dll!System.Net.ConnectStream.System.Net.ICloseEx.CloseEx(System.Net.CloseExState closeState) + 0x26 bytes    
System.dll!System.Net.ConnectStream.CloseInternal(bool internalCall) + 0x1a bytes   
System.dll!System.Net.HttpWebRequest.EndWriteHeaders_Part2() + 0x180 bytes  
System.dll!System.Net.HttpWebRequest.EndWriteHeaders(bool async) + 0x6c bytes   
System.dll!System.Net.HttpWebRequest.WriteHeadersCallback(System.Net.WebExceptionStatus errorStatus, System.Net.ConnectStream stream, bool async) + 0x14 bytes  
System.dll!System.Net.ConnectStream.WriteHeaders(bool async) + 0x2b5 bytes  
System.dll!System.Net.HttpWebRequest.EndSubmitRequest() + 0x8a bytes    
System.dll!System.Net.HttpWebRequest.SetRequestSubmitDone(System.Net.ConnectStream submitStream) + 0x11d bytes  
System.dll!System.Net.Connection.CompleteConnection(bool async, System.Net.HttpWebRequest request) + 0x16c bytes    
System.dll!System.Net.Connection.CompleteStartConnection(bool async, System.Net.HttpWebRequest httpWebRequest) + 0x167 bytes    
System.dll!System.Net.Connection.CompleteStartRequest(bool onSubmitThread, System.Net.HttpWebRequest request, System.Net.TriState needReConnect) + 0xed bytes   
System.dll!System.Net.Connection.SubmitRequest(System.Net.HttpWebRequest request, bool forcedsubmit) + 0x3b3 bytes  
System.dll!System.Net.ServicePoint.SubmitRequest(System.Net.HttpWebRequest request, string connName) + 0x9b bytes   
System.dll!System.Net.HttpWebRequest.SubmitRequest(System.Net.ServicePoint servicePoint) + 0x173 bytes  
System.dll!System.Net.HttpWebRequest.GetResponse() + 0x33c bytes    
Elasticsearch.Net.dll!Elasticsearch.Net.Connection.HttpConnection.DoSynchronousRequest(System.Net.HttpWebRequest request, byte[] data, Elasticsearch.Net.Connection.Configuration.IRequestConfiguration requestSpecificConfig) Line 219 + 0xb bytes C#
Elasticsearch.Net.dll!Elasticsearch.Net.Connection.HttpConnection.HeaderOnlyRequest(System.Uri uri, string method, Elasticsearch.Net.Connection.Configuration.IRequestConfiguration requestSpecificConfig) Line 77 + 0x13 bytes C#
Elasticsearch.Net.dll!Elasticsearch.Net.Connection.HttpConnection.HeadSync(System.Uri uri, Elasticsearch.Net.Connection.Configuration.IRequestConfiguration requestSpecificConfig) Line 53 + 0x15 bytes C#
Elasticsearch.Net.dll!Elasticsearch.Net.Connection.Transport.Ping(Elasticsearch.Net.Connection.RequestState.ITransportRequestState requestState) Line 74 + 0x36 bytes   C#
Elasticsearch.Net.dll!Elasticsearch.Net.Connection.Transport.DoRequest<Nest.IndicesOperationResponse>(Elasticsearch.Net.Connection.RequestState.TransportRequestState<Nest.IndicesOperationResponse> requestState) Line 288 + 0xc bytes C#
Elasticsearch.Net.dll!Elasticsearch.Net.Connection.Transport.DoRequest<Nest.IndicesOperationResponse>(string method, string path, object data, Elasticsearch.Net.IRequestParameters requestParameters) Line 263 + 0x31 bytes    C#
Elasticsearch.Net.dll!Elasticsearch.Net.ElasticsearchClient.DoRequest<Nest.IndicesOperationResponse>(string method, string path, object data, Elasticsearch.Net.IRequestParameters requestParameters) Line 56 + 0x52 bytes  C#
Elasticsearch.Net.dll!Elasticsearch.Net.ElasticsearchClient.IndicesCreatePost<Nest.IndicesOperationResponse>(string index, object body, System.Func<Elasticsearch.Net.CreateIndexRequestParameters,Elasticsearch.Net.CreateIndexRequestParameters> requestParameters) Line 10581 + 0x3d bytes   C#
Nest.dll!Nest.RawDispatch.IndicesCreateDispatch<Nest.IndicesOperationResponse>(Nest.ElasticsearchPathInfo<Elasticsearch.Net.CreateIndexRequestParameters> pathInfo, object body) Line 1274 + 0xe5 bytes C#
Nest.dll!Nest.ElasticClient.CreateIndex.AnonymousMethod__f8(Nest.ElasticsearchPathInfo<Elasticsearch.Net.CreateIndexRequestParameters> p, Nest.ICreateIndexRequest d) Line 17 + 0x34 bytes  C#
Nest.dll!Nest.ElasticClient.Dispatch<Nest.ICreateIndexRequest,Elasticsearch.Net.CreateIndexRequestParameters,Nest.IndicesOperationResponse>(Nest.ICreateIndexRequest descriptor, System.Func<Nest.ElasticsearchPathInfo<Elasticsearch.Net.CreateIndexRequestParameters>,Nest.ICreateIndexRequest,Elasticsearch.Net.ElasticsearchResponse<Nest.IndicesOperationResponse>> dispatch) Line 84 + 0x11 bytes C#
Nest.dll!Nest.ElasticClient.CreateIndex(System.Func<Nest.CreateIndexDescriptor,Nest.CreateIndexDescriptor> createIndexSelector) Line 15 + 0x32 bytes    C#
Nest.dll!Nest.CreateIndexExtensions.CreateIndex(Nest.IElasticClient client, string index, System.Func<Nest.CreateIndexDescriptor,Nest.CreateIndexDescriptor> createIndexSelector) Line 22 + 0x2a bytes  C#
Evaluation of: client.CreateIndex("test")   

Doing the exact same thing, but NOT using a connection pool works just fine.

Here is the info from my ES instance:

{
    status: 200
    name: search2.localdomain
    version: {
        number: 1.1.1
        build_hash: f1585f096d3f3985e73456debdc1a0745f512bbc
        build_timestamp: 2014-04-16T14:27:12Z
        build_snapshot: false
        lucene_version: 4.7
    }
    tagline: You Know, for Search
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions