gpt4 book ai didi

php - 在 PHP 中通过 Hive/Thrift 查询数据库不起作用

转载 作者:可可西里 更新时间:2023-11-01 14:23:05 25 4
gpt4 key购买 nike

我正在尝试通过 PHP 中的 Hive/Thrift 查询数据库。但是,我不断收到错误消息:

TSocket: timed out reading 4 bytes from XYZ

我正在使用来自

的代码

https://cwiki.apache.org/Hive/hiveclient.html#HiveClient-PHP

连同这个 PHP Thrift 客户端

https://github.com/garamon/php-thrift-hive-client

我的代码:

<?php

$socket = new TSocket( 'XYZ', 12345 );

$socket->setSendTimeout(30 * 1000);
$socket->setRecvTimeout(30 * 1000);

$transport = new TBufferedTransport( $socket, 1024, 1024 );
$protocol = new TBinaryProtocol( $transport );

$client = new ThriftHiveClientEx( $protocol );

$transport->open();

$client->execute("my query");

?>

注意 - 我可以通过控制台(telnet 命令)与 XYZ 连接。

我愿意提供任何帮助。谢谢。

最佳答案

从那些完全相同的资源开始时,我遇到了类似的问题。事实证明,代码无法识别它是否已超时或是否阻塞了端口。我发现这篇文章对我有帮助:

https://issues.apache.org/jira/browse/THRIFT-347

在您的 TSocket.php 代码 ( garamon_base_dir/lib/transport ) 中,您必须编辑大约第 223 行到 236 行。

它说的地方:

if( $buf === FALSE || $buf === '' ) { ...
and
if( $md['timed_out'] ) { ...
and then again
if( $md[timed_out'] ) { ...

更改为(分别):

if( $buf === FALSE ) { ...
and
if( true === $md['timed_out'] && false === $md['blocked'] )
and finally
if( true === $md['timed_out'] && false === $md['blocked'] )

然后它在这个修复后开始工作。祝你好运!

关于php - 在 PHP 中通过 Hive/Thrift 查询数据库不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17524076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com