tapplicationexception:必填字段“client\u protocol”未设置

czq61nw1  于 2021-06-02  发布在  Hadoop
关注(0)|答案(1)|浏览(546)

我在发展一个节俭的客户,
我已经在我的机器上构建了一个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);
vjrehmav

vjrehmav1#

我相信这是hivejdbc版本的问题。此解决方案可能会解决您的问题:必填字段“client\u protocol”未设置

相关问题