简体   繁体   English

Cassandra PHP 驱动程序挂起

[英]Cassandra PHP Driver hangs

When connecting to the cluster via cluster->connect() the PHP script hangs.通过 cluster->connect() 连接到集群时,PHP 脚本挂起。

While I try this with the nodejs driver :当我尝试使用 nodejs 驱动程序时

const cassandra = require('cassandra-driver');
const client = new cassandra.Client({
contactPoints: ['127.0.0.1'],
localDataCenter: 'datacenter1',
keyspace: 'test'
});
const query = 'SELECT * FROM mytable';
client.execute(query).then(console.log).catch( console.log );

We get the following output :我们得到以下 output

ResultSet {
info: {
queriedHost: '127.0.0.1:9042',
triedHosts: { '127.0.0.1:9042': null },
speculativeExecutions: 0,
achievedConsistency: 10,
traceId: undefined,
warnings: undefined,
customPayload: undefined,
isSchemaInAgreement: true
},
rows: [ Row { id: 'test' } ],
rowLength: 1,
columns: [ { name: 'id', type: [Object] } ],
pageState: null,
nextPage: undefined,
nextPageAsync: undefined
}

When we do this with PHP it hangs :当我们使用 PHP 执行此操作时,它会挂起

<?php
$cluster   = \Cassandra::cluster()
->withContactPoints( '127.0.0.1' )
->withPort( 9042 )
->build();
// This will happen immediately
// var_dump( 'Built!' );exit;
$session   = $cluster->connect( 'test' );
// This hangs. It never dumps 'Connected!'.
var_dump( 'Connected!' );exit;
var_dump( $session->execute( new \Cassandra\SimpleStatement( 'select * from mytable' ), array() ) );

Below are attached the files needed .下面附上所需的文件

index.php -> https://pastebin.com/iihpJfpW index.php -> https://pastebin.com/iihpJfpW

Vagrantfile -> https://pastebin.com/BkPwynxy流浪文件-> https://pastebin.com/BkPwynxy

cassandra.repo -> https://pastebin.com/LbraCY3f cassandra.repo -> https://pastebin.com/LbraCY3f

index.js -> https://pastebin.com/TSPc0bLm index.js -> https://pastebin.com/TSPc0bLm

  1. Make new folder "cassandraTest"制作新文件夹“cassandraTest”
  2. Put Vagrantfile inside the folder将 Vagrantfile 放入文件夹中
  3. Make new directory in "cassandraTest" called "provision"在“cassandraTest”中创建名为“provision”的新目录
  4. Put cassandra.repo in there把 cassandra.repo 放在那里
  5. vagrant up vagrant向上

NOTE :注意

This is not a Vagrant issue, as the same problem occurs in our Stage environment running CentOS 7.6这不是 Vagrant 问题,因为在我们运行 CentOS 7.6 的舞台环境中也会出现同样的问题

Environment:环境:

CentOS 7.6 CentOS 7.6

Cassandra 3.11.6 Native Protocol v4 Cassandra 3.11.6 原生协议 v4

NodeJs 12 NodeJs Cassandra Driver 4.5.0 NodeJs 12 NodeJs Cassandra 驱动程序 4.5.0

PHP 7.2 PHP Cassandra Driver ( latest, installed via yum install -y php72-php-pecl-cassandra.x86_64 from remi ) PHP 7.2 PHP Cassandra 驱动程序(最新,通过 yum install -y php72-php-pecl-cassandra.x86_64 安装)

Vagrant 2.2.7 Oracle VirtualBox Version 6.1.4 r136177 (Qt5.6.2) Vagrant 2.2.7 Oracle VirtualBox 版本 6.1.4 r136177 (Qt5.6.2)

Looking at the date you asked and the symptoms, I think you are hitting this bug .查看您询问的日期和症状,我认为您遇到了这个错误

Try upgrading the cassandra-cpp-driver to the v2.15.2 and see if it works.尝试将cassandra-cpp-driver升级到 v2.15.2 并查看它是否有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM