我试图通过PHP中的Hive / Thrift查询数据库。然而,我经常会遇到一个错误:
TSocket:超时读取XYZ中的4个字节 $ c我使用
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 XYZI'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查询数据库不起作用
发布评论