1. In C # write thrift service side, to the corresponding HTTP request, in the structure of the transmission, you will encounter a problem, that is (in the network) transmission of data is particularly slow,
This is due to the fact that the data is used in the tstreamtransport resulting in each data transmission, a connection is established.
2. Workaround:
The overrides in Thttphandler can be reduced to the following.
12345678910111213141516171819202122232425262728293031323334 |
public void ProcessRequest(Stream input, Stream output)
{
//TTransport transport = new TStreamTransport(input,output);
TTransport inTransport =
new TStreamTransport(input, output);
//在out加入缓存机制
TBufferedTransport outTransport =
new TBufferedTransport((TStreamTransport)inTransport);
//TTransport transport = new TStreamTransport(input, output);
TProtocol inputProtocol =
null
;
TProtocol outputProtocol =
null
;
try
{
inputProtocol = inputProtocolFactory.GetProtocol(inTransport);
outputProtocol = outputProtocolFactory.GetProtocol(outTransport);
while
(processor.Process(inputProtocol, outputProtocol)) { }
}
catch
(TTransportException)
{
// Client died, just move on
}
catch
(TApplicationException tx)
{
Console.Error.Write(tx);
}
catch
(Exception x)
{
Console.Error.Write(x);
}
inTransport.Close();
outTransport.Close();
}
|
Slow solution to Thttphandler transmission data in thrift in C language