Skip to content

Commit 82b506d

Browse files
committed
Merge pull request #1192 from elasticsearch/fix/thrift-failover-test
Fix #1166 failing thrift test
2 parents f35e92a + 4095d3d commit 82b506d

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ public ThriftConnection(IConnectionConfigurationValues connectionSettings, TProt
4848
var protocol = protocolFactory == null ? new TBinaryProtocol(transport) : protocolFactory.GetProtocol(transport);
4949

5050
var client = new Rest.Client(protocol);
51+
tsocket.ConnectTimeout = this._connectionSettings.PingTimeout.GetValueOrDefault(200);
5152
tsocket.Timeout = this._connectionSettings.Timeout;
5253
tsocket.TcpClient.SendTimeout = this._connectionSettings.Timeout;
5354
tsocket.TcpClient.ReceiveTimeout = this._connectionSettings.Timeout;
54-
//tsocket.TcpClient.NoDelay = true;
55+
tsocket.TcpClient.NoDelay = true;
5556

5657
queue.Enqueue(client);
5758

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public TSocket(TcpClient client)
4444
}
4545
}
4646

47-
public TSocket(string host, int port) : this(host, port, 0)
47+
public TSocket(string host, int port)
48+
: this(host, port, 0)
4849
{
4950
}
5051

@@ -57,6 +58,8 @@ public TSocket(string host, int port, int timeout)
5758
InitSocket();
5859
}
5960

61+
public int ConnectTimeout { get; set; }
62+
6063
public int Timeout
6164
{
6265
set { client.ReceiveTimeout = client.SendTimeout = timeout = value; }
@@ -118,14 +121,14 @@ public override void Open()
118121
InitSocket();
119122
}
120123

121-
122-
var connectionRequest = client.BeginConnect(host, port, null, null);
123-
var connected = connectionRequest.AsyncWaitHandle.WaitOne(timeout);
124124

125-
if (!connected)
126-
{
127-
throw new TTransportException("Failed to connect");
128-
}
125+
var connectionRequest = client.BeginConnect(host, port, null, null);
126+
var connected = connectionRequest.AsyncWaitHandle.WaitOne(this.ConnectTimeout);
127+
128+
if (!connected)
129+
{
130+
throw new TTransportException("Failed to connect");
131+
}
129132

130133
inputStream = client.GetStream();
131134
outputStream = client.GetStream();

0 commit comments

Comments
 (0)