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 @@ -48,10 +48,11 @@ public ThriftConnection(IConnectionConfigurationValues connectionSettings, TProt
var protocol = protocolFactory == null ? new TBinaryProtocol(transport) : protocolFactory.GetProtocol(transport);

var client = new Rest.Client(protocol);
tsocket.ConnectTimeout = this._connectionSettings.PingTimeout.GetValueOrDefault(200);
tsocket.Timeout = this._connectionSettings.Timeout;
tsocket.TcpClient.SendTimeout = this._connectionSettings.Timeout;
tsocket.TcpClient.ReceiveTimeout = this._connectionSettings.Timeout;
//tsocket.TcpClient.NoDelay = true;
tsocket.TcpClient.NoDelay = true;

queue.Enqueue(client);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public TSocket(TcpClient client)
}
}

public TSocket(string host, int port) : this(host, port, 0)
public TSocket(string host, int port)
: this(host, port, 0)
{
}

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

public int ConnectTimeout { get; set; }

public int Timeout
{
set { client.ReceiveTimeout = client.SendTimeout = timeout = value; }
Expand Down Expand Up @@ -118,14 +121,14 @@ public override void Open()
InitSocket();
}


var connectionRequest = client.BeginConnect(host, port, null, null);
var connected = connectionRequest.AsyncWaitHandle.WaitOne(timeout);

if (!connected)
{
throw new TTransportException("Failed to connect");
}
var connectionRequest = client.BeginConnect(host, port, null, null);
var connected = connectionRequest.AsyncWaitHandle.WaitOne(this.ConnectTimeout);

if (!connected)
{
throw new TTransportException("Failed to connect");
}

inputStream = client.GetStream();
outputStream = client.GetStream();
Expand Down