我正在尝试通过 PHP 中的 Hive/Thrift 查询数据库。但是,我不断收到错误:
TSocket: timed out reading 4 bytes from XYZ
我正在使用来自的代码
https://cwiki.apache.org/Hive/hiveclient.html#HiveClient-PHP https://cwiki.apache.org/Hive/hiveclient.html#HiveClient-PHP
以及这个 PHP Thrift 客户端
https://github.com/garamon/php-thrift-hive-client https://github.com/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");
?>
注意 - 我可以通过控制台(telnet 命令)连接 XYZ。
我将不胜感激任何帮助。谢谢。
当我从这些完全相同的资源开始时遇到了类似的问题。事实证明,代码无法识别是否已超时或是否阻塞了端口。我发现这篇文章对我有帮助:
https://issues.apache.org/jira/browse/THRIFT-347 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'] )
然后它在修复后开始工作。祝你好运!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)