TApplicationException:必填字段' client_protocol'没有设定

时间:2014-10-10 13:30:13

标签: hadoop hive thrift thrift-protocol

我正在开发一个节俭客户端,

我已经在我的机器上构建了一个thrift hive服务器(apache-hive-0.14.0),并且还可以访问Cloudera Dist Hive 4.6.0

当我将thrift客户端连接到CDH客户端时出现以下错误:

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

我正在将正确的协议传递给服务器,但似乎有些事情已经超过它....

此外,如果我指向localhost(我的hive服务器正在运行),每件事情似乎都运转良好....

请告诉我这里有什么问题......

代码:

       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);

1 个答案:

答案 0 :(得分:0)

我认为这是hive-jdbc版本的问题。此解决方案可以解决您的问题:Required field 'client_protocol' is unset