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

编程入门 行业动态 更新时间:2024-10-26 03:31:30
本文介绍了通过PHP中的Hive / Thrift查询数据库不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图通过PHP中的Hive / Thrift查询数据库。然而,我经常会遇到一个错误:

TSocket:超时读取XYZ中的4个字节 我使用

cwiki.apache/Hive/hiveclient.html#HiveClient-PHP

以及此PHP Thrift客户端

github/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->执行(我的查询); ?>

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

我会提供任何帮助。感谢。

解决方案

在使用完全相同的资源时,我遇到了类似的问题。事实证明,代码没有意识到它是否超时或是否阻塞端口。我发现这篇文章对我有帮助:

issues.apache/jira/browse/THRIFT-347

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

它说:

if($ buf === FALSE || $ buf ===''){... 和 if($ md ['timed_out']){... $ ($ md [timed_out']){...

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

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

I'm trying to query a database through Hive/Thrift in PHP. However, I am constantly getting an error:

TSocket: timed out reading 4 bytes from XYZ

I'm using a code from

cwiki.apache/Hive/hiveclient.html#HiveClient-PHP

along with this PHP Thrift Client

github/garamon/php-thrift-hive-client

My code:

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

Note - I am able to connect with XYZ through console (telnet command).

I would appriciate any help. Thanks.

解决方案

I had a similar problem when starting with those exact same resources. It turns out the code is not recognizing whether it has timed out or whether it is blocking the port. I found this article which helped me:

issues.apache/jira/browse/THRIFT-347

In your TSocket.php code ( garamon_base_dir/lib/transport ) you have to edit approximately lines 223 through 236.

Where it says:

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

change to (respectively):

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

Then it started working after this fix. Good luck!

更多推荐

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

本文发布于:2023-10-23 19:53:07,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不起作用   数据库   PHP   Hive   Thrift

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!