你好,我試圖建立一個nodejs客戶端查詢我的蜂房數據庫使用節儉,但我面臨一個奇怪的問題...我已經生成我的nodejs客戶端API與節儉(thrift -r --gen js:node TCLIService.thrift
與TCLIService是節儉文件定義Hive服務),現在我嘗試連接到Hive,但是我的OpenSession正在等待...也許我沒有做正確的調用,但是我沒有在網上找到任何最新的東西(每個節點/節點/蜂巢項目是4或5歲)。你可以看看並告訴我,如果我做錯了嗎?感謝Hive - Thrift - readMessageBegin中缺少的版本,舊客戶端?
TCLIService.thrift:
// OpenSession()
//
// Open a session (connection) on the server against
// which operations may be executed.
struct TOpenSessionReq {
// The version of the HiveServer2 protocol that the client is using.
1: required TProtocolVersion client_protocol = TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8
// Username and password for authentication.
// Depending on the authentication scheme being used,
// this information may instead be provided by a lower
// protocol layer, in which case these fields may be
// left unset.
2: optional string username
3: optional string password
// Configuration overlay which is applied when the session is
// first created.
4: optional map<string, string> configuration
}
service TCLIService {
TOpenSessionResp OpenSession(1:TOpenSessionReq req);
}
代碼的NodeJS: VAR sessionHandle = '';
function openSession(config) {
openSessReq = new ttypes.TOpenSessionReq();
openSessReq.client_protocol = ttypes.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8;
openSessReq.username = config.hiveUser;
openSessReq.password = config.hivePassword;
console.log("openSessReq = " + JSON.stringify(openSessReq));
console.log("Before OpenSession : sessionHandle = " + sessionHandle);
sessionHandle = client.OpenSession(openSessReq, function (err, result){
console.log('handler fired ... ');
if (err) {
console.error("error : " + err);
} else {
console.log("result : " + result);
}
});
console.log("After OpenSession : sessionHandle = " + sessionHandle);
}
connection.on('error', function(err) {
/*Error detected, print the error*/
console.error(err);
/*Close the program with error code*/
process.exit(1)
});
console.log('Error handler registered ...')
connection.on('connect', function(){
console.log('Connected ...');
/*Init session*/
console.log(client);
openSession(config);
}
我的輸出如下:
CreateConnection DONE ...
Error handler registered ...
Connect handler registered ...
Connected ...
{ output:
TBufferedTransport {
defaultReadBufferSize: 1024,
writeBufferSize: 512,
inBuf: <Buffer e8 19 2b 03 00 00 00 00 b0 1a 2b 03 00 00 00 00 e8 18 2b 03 00 00 00 00 f0 18 2b 03 00 00 00 00 b0 19 2b 03 00 00 00 00 78 1a 2b 03 00 00 00 00 70 1d ... >,
readCursor: 0,
writeCursor: 0,
outBuffers: [],
outCount: 0,
onFlush: [Function],
client: [Circular] },
pClass: [Function: TBinaryProtocol],
_seqid: 0,
_reqs: {} }
openSessReq = {"client_protocol":7,"username":"root","password":"root","configuration":null}
Before OpenSession : sessionHandle =
After OpenSession : sessionHandle = undefined
^C
該腳本運行下去......如果我改變這樣的連接工作HiveServer我面對一個錯誤的端口或關機,但我可以找出爲什麼openSession不是!感謝您的幫助
編輯: 我檢查了我的日誌和NOSASL標識是問題...我已經固定的(我覺得)這個問題現在得到以下錯誤:
客戶:
{ [Error: write EPIPE]
code: 'EPIPE',
errno: 'EPIPE',
syscall: 'write',
address: undefined }
服務器:
2016-02-17 13:36:37,152 ERROR org.apache.thrift.server.TThreadPoolServer: [HiveServer2-Handler-Pool: Thread-24]: Thrift error occurred during processing of message.
org.apache.thrift.protocol.TProtocolException: Missing version in readMessageBegin, old client?
at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:228)
at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:27)
at org.apache.hive.service.auth.TSetIpAddressProcessor.process(TSetIpAddressProcessor.java:56)
at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:285)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
我讀過的問題,必須由使用了錯誤的協議層提出了...我使用TBinaryProtocol它是一個問題?
如果您有任何問題,請提出兩個問題。如果你只有一個,請刪除其餘的。 – JensG