Skip to content

Commit 9c2d482

Browse files
committed
Merge pull request #1163 from eddyzanda/develop
Thrift connection timeout #1159
2 parents bfd2866 + d7c48a8 commit 9c2d482

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Connections/Elasticsearch.Net.Connection.Thrift/ThriftConnection.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public ThriftConnection(IConnectionConfigurationValues connectionSettings)
4343
{
4444
var host = uri.Host;
4545
var port = uri.Port;
46-
var tsocket = new TSocket(host, port);
46+
var tsocket = new TSocket(host, port, this._connectionSettings.Timeout);
4747
var transport = new TBufferedTransport(tsocket, 1024);
4848
var protocol = new TBinaryProtocol(transport);
4949
var client = new Rest.Client(protocol);

src/Connections/Elasticsearch.Net.Connection.Thrift/Transport/TSocket.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,15 @@ public override void Open()
118118
InitSocket();
119119
}
120120

121-
client.Connect(host, port);
121+
122+
var connectionRequest = client.BeginConnect(host, port, null, null);
123+
var connected = connectionRequest.AsyncWaitHandle.WaitOne(timeout);
124+
125+
if (!connected)
126+
{
127+
throw new TTransportException("Failed to connect");
128+
}
129+
122130
inputStream = client.GetStream();
123131
outputStream = client.GetStream();
124132
}

0 commit comments

Comments
 (0)