Can't connect to standalone mongodb: No candidate servers found - php

I have debian dev server with stock mongodb; php 5.4 and pecl mongodb drivers v1.4.3.
I tried to create simple conntection using PHP Cli and got exception:
php -r "MongoLog::setLevel(MongoLog::ALL); MongoLog::setModule(MongoLog::ALL); new MongoClient('mongodb://127.0.0.1:27017', array());"
the output below:
PHP Notice: PARSE INFO: Parsing mongodb://127.0.0.1:27017 in Command line code on line 1
PHP Notice: PARSE INFO: - Found node: 127.0.0.1:27017 in Command line code on line 1
PHP Notice: PARSE INFO: - Connection type: STANDALONE in Command line code on line 1
PHP Notice: CON INFO: mongo_get_read_write_connection: finding a STANDALONE connection in Command line code on line 1
PHP Notice: CON INFO: connection_create: creating new connection for 127.0.0.1:27017 in Command line code on line 1
PHP Notice: CON INFO: stream_connect: Not establishing SSL for 127.0.0.1:27017 in Command line code on line 1
PHP Notice: CON INFO: get_server_flags: start in Command line code on line 1
PHP Notice: CON FINE: send_packet: read from header: 36 in Command line code on line 1
PHP Notice: CON FINE: send_packet: data_size: 73 in Command line code on line 1
PHP Notice: CON FINE: get_server_flags: can't find maxBsonObjectSize, defaulting to 4194304 in Command line code on line 1
PHP Notice: CON FINE: get_server_flags: can't find maxMessageSizeBytes, defaulting to 8388608 in Command line code on line 1
PHP Notice: CON INFO: get_server_flags: found server type: UNKNOWN? in Command line code on line 1
PHP Notice: CON INFO: is_ping: pinging 127.0.0.1:27017;-;.;29554 in Command line code on line 1
PHP Notice: CON FINE: send_packet: read from header: 36 in Command line code on line 1
PHP Notice: CON FINE: send_packet: data_size: 69 in Command line code on line 1
PHP Notice: CON INFO: is_ping: last pinged at 1376577544; time: 0ms in Command line code on line 1
PHP Notice: REPLSET FINE: finding candidate servers in Command line code on line 1
PHP Notice: REPLSET FINE: - all servers in Command line code on line 1
PHP Notice: REPLSET FINE: filter_connections: adding connections: in Command line code on line 1
PHP Notice: REPLSET FINE: filter_connections: done in Command line code on line 1
PHP Notice: REPLSET FINE: limiting by seeded/discovered servers in Command line code on line 1
PHP Notice: REPLSET FINE: limiting by seeded/discovered servers: done in Command line code on line 1
PHP Notice: REPLSET FINE: limiting by credentials in Command line code on line 1
PHP Notice: REPLSET FINE: limiting by credentials: done in Command line code on line 1
PHP Fatal error: Uncaught exception 'MongoConnectionException' with message 'No candidate servers found' in Command line code:1
Stack trace:
#0 Command line code(1): MongoClient->__construct('mongodb://127.0...', Array)
#1 {main}
thrown in Command line code on line 1
I have found workaround - is downgrade dirver version to 1.3.6; but it is not a solution.

Take a look at: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
I solved my problem after installing 10-gen version mongodb.

Had the same problem today, downgraded to the 1.3.6 version of mongo driver in pecl "worked" for me... System: Debian Squeeze
This does the job for you:
pecl uninstall mongo
pecl install mongo-1.3.6

Related

PHP file not running in CRON/CLI

I have to run a php file every 5 seconds , and have two issues
1. The file works perfectly when opened in a browser, but running the 'php myfile.php' command fails and produces the following error
PHP Warning: include_once(../tutadmin/config/config.php): failed to open stream: No such file or directory in /var/www/html/cron/teacher_status_cron.php on line 3
PHP Warning: include_once(): Failed opening '../tutadmin/config/config.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/cron/teacher_status_cron.php on line 3
PHP Notice: Use of undefined constant TBL_USER - assumed 'TBL_USER' in /var/www/html/cron/teacher_status_cron.php on line 5
PHP Notice: Use of undefined constant TEACHER_USER_GROUP_ID - assumed 'TEACHER_USER_GROUP_ID' in /var/www/html/cron/teacher_status_cron.php on line 9
PHP Notice: Undefined variable: current_user_id in /var/www/html/cron/teacher_status_cron.php on line 14
PHP Notice: Undefined variable: current_date_time in /var/www/html/cron/teacher_status_cron.php on line 15
PHP Notice: Undefined variable: dbc in /var/www/html/cron/teacher_status_cron.php on line 20
PHP Fatal error: Uncaught Error: Call to a member function Query() on null in /var/www/html/cron/teacher_status_cron.php:20
Stack trace:
#0 {main}
thrown in /var/www/html/cron/teacher_status_cron.php on line 20
Crontab will not run the program every 5 seconds, only every minute at best.
Edit: the file does not work outside of cron in the CLI either, only on a web browser.. Cron is not the issue.
Because you have not right permissions on file, your cron can not open file, change permissions.

libssh2 unable to exchange encryption keys

I'm trying to connect to a SFTP server with the following command:
<?php
ssh2_connect("my-host.com", 443, array("client_to_server" => array("mac" => "hmac-sha2-256,hmac-sha2-512,umac-64#openssh.com")));
But I get the following error message:
PHP Warning: ssh2_connect(): Error starting up SSH connection(-5): Unable to exchange encryption keys in Command line code on line 1
PHP Stack trace:
PHP 1. {main}() Command line code:0
PHP 2. ssh2_connect() Command line code:1
PHP Warning: ssh2_connect(): Unable to connect to my-host.com in Command line code on line 1
PHP Stack trace:
PHP 1. {main}() Command line code:0
PHP 2. ssh2_connect() Command line code:1
And when I check the logs of my SFTP server, I can see:
2016-08-17 15:32:43,104 mod_sftp/0.9.9[10701]: no shared client-to-server MAC algorithm found (client sent 'hmcom', server sent 'hmac-sha2-256,hmac-sha2-512,umac-64#openssh.com')
Could you help me?
Ben

Error installing Composer on web host via SSH

I'm able to SSH into my web host(Bluehost) just fine. In my root folder(public_html) I installed composer with the following command..
curl -sS https://getcomposer.org/installer | php
When I run "php composer.phar" I get an error that pops up in the command line.
[ErrorException]
Invalid argument supplied for foreach()
I notice in my root folder where I installed composer I keep getting a file called error.log that includes the following...
PHP Notice: Undefined variable: argv in - on line 13
PHP Notice: Undefined index: argv in phar:///home2/websitename/public_html/composer.phar/vendor/symfony/console/Input/ArgvInput.php on line 55
PHP Warning: array_shift() expects parameter 1 to be array, null given in phar:///home2/websitename/public_html/composer.phar/vendor/symfony/console/Input/ArgvInput.php on line 59
PHP Warning: Invalid argument supplied for foreach() in phar:///home2/websitename/public_html/composer.phar/vendor/symfony/console/Input/ArgvInput.php on line 285
Not sure what to do next. My end goal is to install Laravel. Any assistance would be appreciated.

PHP MongoDB Driver selecting secondary instead of primary mongo db node intermittently

I have simple setup with two mongo db nodes (Node A and B). These nodes are also running apache server having php rest api code.
Below are the two scenarios and 2nd is giving problems.
Scenario 1:
1) Node A is mongodb primary and Node B mongodb secondary.
2) REST request sent to Node A, sucessfully processed.
Scenario 2:
1) Node A is mongodb primary and Node B mongodb secondary.
2) REST request sent to Node B, request is processed intermittently.
Scenario 2 logs:
PHP Notice: REPLSET INFO: pick server: random element 0 in /var/www/html/api/lib/mongo.php on line 396
PHP Notice: REPLSET INFO: - connection: type: SECONDARY, socket: 42, ping: 0, hash: secondary.host:27017;-;.;27676 in /var/www/html/api/lib/test.php on line 396
PHP Notice: IO FINE: getting reply in /var/www/html/api/lib/test.php on line 396
PHP Notice: IO FINE: getting cursor header in /var/www/html/api/lib/test.php on line 396
PHP Notice: CON FINE: No timeout changes for secondary.host:27017;-;.;27676 in /var/www/html/api/lib/test.php on line 396
PHP Notice: IO FINE: getting cursor body in /var/www/html/api/lib/test.php on line 396
PHP Notice: CON FINE: No timeout changes for secondary.host:27017;-;.;27676 in /var/www/html/api/lib/test.php on line 396
PHP Notice: CON FINE: mongo_connection_destroy: Destroying connection object for secondary.host:27017;-;.;27676 in /var/www/html/api/lib/test.php on line 396
PHP Notice: CON FINE: mongo_connection_destroy: Closing socket for secondary.host:27017;-;.;27676. in /var/www/html/api/lib/test.php on line 396
PHP Fatal error: Uncaught exception 'MongoCursorException' with message 'secondary.host:27017: not master and slaveOk=false'
For scenario 2, it should always select node A but sometimes it choose node B and fails.
PHP code :
$this->mongo = new \MongoClient ( $list_of_servers, array ('replicaSet' => 'rs0') );
Do I have to make some configuration changes? How to fix this issue?
Thanks
Other information :
MongoDB Version -> 3.0.6
PHP MongoDB Driver -> 1.6.9
PHP version -> 5.3.3
OS -> RedHat

phpvideotoolkit class errors on xampp installed on windows server 2008

find i m trying to convert sequence of images into a video. and for that i canme to know about the ffmpeg class.
the only wrapper class that i found is phpvideotoolkit but i m not able to work with it.
i installed phpvideotoolkit on xampp on my windows 2008 server . but it is throwing alor of errors
This example shows you how to extract a specific frame from a movie.
Notice: Undefined property: PHPVideoToolkit::$_tmb_directory in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 869
Notice: Undefined offset: 0 in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 877
PHPVideoToolkit Error: Execute error. Output for file "C:\xampp\htdocs\phpvideo\examples\working\to-be-processed\MOV00007.3gp" was not found. No images were generated.
Notice: Undefined property: PHPVideoToolkit::$_tmb_directory in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 869
Notice: Undefined offset: 0 in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 877
PHPVideoToolkit Error: Execute error. Output for file "C:\xampp\htdocs\phpvideo\examples\working\to-be-processed\Video000.3gp" was not found. No images were generated.
Notice: Undefined property: PHPVideoToolkit::$_tmb_directory in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 869
Notice: Undefined offset: 0 in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 877
PHPVideoToolkit Error: Execute error. Output for file "C:\xampp\htdocs\phpvideo\examples\working\to-be-processed\cat.mpeg" was not found. No images were generated.
example
PHPVideoToolkit Error: Execute error. Output for file "C:\xampp\htdocs\phpvideo\examples\working\tmp\1336156630-4fa421d69357d\tmp_%d.jpg" was not found. Please check server write permissions and/or available codecs compiled with FFmpeg. You can check the encode decode availability by inspecting the output array from PHPVideoToolkit::getFFmpegInfo().
i m trying to make it work since last many hours but no luck
Also, for this code :
$srcFile = "test-mpeg.mpg";
$ffmpegObj = new ffmpeg_movie($srcFile);
i am gettign error that it cant file the file. i believe its something to do with permissions but i m not able to figure out
fpoen , fwrite , file_put_contents all are working fine without any permissions problems.
can anyone please guide me in the write direction. what do i need to do to make this phpvideotoolkit work

Categories