0

I am developing a thrift client,

I have build a thrift hive server(apache-hive-0.14.0) on my machine and am also have access to Cloudera Dist Hive 4.6.0

When i connect thrift client to CDH client give following error:

TApplicationException: Required field 'client_protocol' is unset!
Struct:TOpenSessionReq(client_protocol:null, username:

I am passing the right protocol to the server but it seems some thing is over riding it....

Moreover if I point to localhost(where i have my hive server running) every thing seems to working fine....

Please let me know what is wrong here....

Code:

       var socket = new TSocket("XXX.XXX.XXX.XXX", 10000);

        TStreamTransport sTransport = (TStreamTransport)socket;

        var transport = new TBufferedTransport(socket);

        underlyingTransport = transport;

        var proto = new TBinaryProtocol(transport);
        var client = new TCLIService.Client(proto);
        transport.Open();

        TOpenSessionReq req = new TOpenSessionReq(TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V6);
        req.Username = "hive";
        req.Password = "hive";

        TOpenSessionResp oSResponse = client.OpenSession(req);
        TSessionHandle sessionHandle = oSResponse.SessionHandle;

        TExecuteStatementReq execReq = new TExecuteStatementReq(sessionHandle, "select * from emp");
        TExecuteStatementResp exeRes= client.ExecuteStatement(execReq);
        TOperationHandle operationHandle = exeRes.OperationHandle;

        TFetchResultsReq fechReq = new TFetchResultsReq(operationHandle,TFetchOrientation.FETCH_FIRST, 1);
        TFetchResultsResp fechRes = client.FetchResults(fechReq);

        TRowSet results = fechRes.Results;
        List<TRow> resultRows = results.Rows;
        foreach (var row in resultRows)
        {
            var val = row.ColVals[0];
            System.Console.WriteLine(val.StringVal);
        }

        TCloseOperationReq closeOprReq = new TCloseOperationReq(operationHandle);
        client.CloseOperation(closeOprReq);

        TCloseSessionReq creq = new TCloseSessionReq(sessionHandle);
        client.CloseSession(creq);
Scott Solmer
  • 3,871
  • 6
  • 44
  • 72
  • 1
    Sounds like this may be an I/O stack error. Is the Cloudera Hive using TFramedTransport instead of TBufferedTransport perhaps? – codeSF Oct 11 '14 at 19:19
  • "*I am passing the right protocol to the server but it seems some thing is overriding it....*" - Nobody is overriding anything. But some servers implicitly require `TFramedTransport`. This is a very common pitfall. According to [this document](https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2) Hive uses threading at the server side, so please check if `TFramedTransport` works. – JensG Oct 12 '14 at 17:10

1 Answers1

0

I believe it is the problem of the hive-jdbc version. This solution may solve your problem: Required field 'client_protocol' is unset

Community
  • 1
  • 1
Feiran
  • 61
  • 9