-
Notifications
You must be signed in to change notification settings - Fork 79
!!! Question !!! about catching Exceptions #94
Comments
nevermind.... figured it out. try { catch( phpcassa\Connection\NoServerAvailable $e ) { |
FYI for other users. |
Are you using the autoloader (autoload.php)? If so, try adding 'use On Mon, Jul 23, 2012 at 5:06 PM, Shaun Arral <
Tyler Hobbs |
Yes. require_once('../phpcass/lib/autoload.php'); It's probably better to catch early (ConnectionPool) rather than what I figured out to do: Catch on ColumnFamily init. my second comment did work. Going to do your suggestion. Thanks. |
Trying to trap when I can't connect to the cluster.
Thank you for your help.
I have looked everywhere (except where an example is, haha) to find an example
I'm kinda new to PHP, but experienced programmer.
I'm going to try this as a script, without using a Class
class CassCore
{
...
function __construct() {
try {
$this->rCONN = new ConnectionPool(self::KS, $this->servers);
}
catch( NoServerAvailable $e ) {
echo "No Connection to Cluster\n";
die("FOUND EXCEPTION\n");
}
catch( phpcassa\Connection\NoServerAvailable $e ) {
echo "No Connection to Cluster\n";
die("FOUND EXCEPTION\n");
}
// Connect to CFs
......
return;
}
and what i receive:
Error connecting to 191.168.1.50: TException: TSocket: Could not connect to 191.168.1.50:9160 (Connection timed out [110])
Error connecting to 191.168.1.101: TException: TSocket: Could not connect to 191.168.1.101:9160 (Connection timed out [110])
Error connecting to 191.168.1.50: TException: TSocket: Could not connect to 191.168.1.50:9160 (Connection timed out [110])
Error connecting to 191.168.1.101: TException: TSocket: Could not connect to 191.168.1.101:9160 (Connection timed out [110])
Fatal error: Uncaught exception 'phpcassa\Connection\NoServerAvailable' with message 'An attempt was made to connect to every server twice, but all attempts failed. The last error was: TException:TSocket: Could not connect to 191.168.1.101:9160 (Connection timed out [110])' in /home/shaun/Documents/Cassandra/phpcass/lib/phpcassa/Connection/ConnectionPool.php:138
Stack trace:
#0 /home/shaun/Documents/Cassandra/phpcass/lib/phpcassa/Connection/ConnectionPool.php(163): phpcassa\Connection\ConnectionPool->make_conn()
#1 /home/shaun/Documents/Cassandra/phpcass/lib/phpcassa/Connection/ConnectionPool.php(257): phpcassa\Connection\ConnectionPool->get()
#2 /home/shaun/Documents/Cassandra/phpcass/lib/phpcassa/Connection/ConnectionPool.php(192): phpcassa\Connection\ConnectionPool->call('describe_keyspa...', 'ip_store')
#3 /home/shaun/Documents/Cassandra/phpcass/lib/phpcassa/ColumnFamily.php(193): phpcassa\Connection\ConnectionPool->describe_keyspace()
#4 /home/shaun/Documents/Cassandra/CassCore.php(67): phpcassa\ColumnFamily->__const in /home/shaun/Documents/Cassandra/phpcass/lib/phpcassa/Connection/ConnectionPool.php on line 138
The text was updated successfully, but these errors were encountered: