Connecting to MongoDB using Lithium li3 Framework - mongodb

I am writing a relatively simple app in the Lithium (li3) Framework. I am using MongoDB as the datastore. My MongoDB database is hosted in the cloud - at MongoHQ.
I am getting intermittent errors when trying to post data. At times it will work - but then I will get an error that says the following:
Fatal error: Uncaught exception 'MongoConnectionException' with
message 'connecting to mongodb://USERNAME:PASSWORD#flame.mongohq.com:27052/DATABASENAME failed:
Operation now in progress' in
/Applications/MAMP/htdocs/quizapp/libraries/lithium/data/source/MongoDb.php:257 Stack trace:
#0 /Applications/MAMP/htdocs/quizapp/libraries/lithium/data/source/MongoDb.php(257): Mongo-
>__construct('mongodb://mongo...', Array) #1
/Applications/MAMP/htdocs/quizapp/libraries/lithium/data/Source.php(90):
lithium\data\source\MongoDb->connect() #2
/Applications/MAMP/htdocs/quizapp/libraries/lithium/data/source/MongoDb.php(160):
lithium\data\Source->_init() #3
/Applications/MAMP/htdocs/quizapp/libraries/lithium/core/Object.php(93):
lithium\data\source\MongoDb->_init() #4
/Applications/MAMP/htdocs/quizapp/libraries/lithium/data/Source.php(73): lithium\core\Object-
>__construct(Array) #5
/Applications/MAMP/htdocs/quizapp/libraries/lithium/data/source/MongoDb.php(156):
lithium\data\Source->__construct(Array) #6 /Applications/MAMP/htdocs/quizapp/libra in
/Applications/MAMP/htdocs/quizapp/libraries/lithium/data/source/MongoDb.php on line 263
I am running this on MAMP on a Mac. I have tried to stop and restart Apache - but it does not seem to fix the problem. However, I do seem to connect to MongoDB 1 out of every 10 to 15 attempts. I cannot figure out any trends.
Any help will be greatly appreciated.
Thank you
Nino

I can see two possible issues here:
A firewall, and a description to turn that off is at: https://groups.google.com/forum/#!msg/mongodb-user/9-DYhQWEo0E/B4UsY53S1IwJ
Slow connections — in some cases a connection to a host is too slow. And since version 1.3.4 of the Mongo PHP driver (which li3 uses) there is great control over timeouts. Have a look at the timeout option at http://www.php.net/manual/en/mongoclient.construct.php — you will most likely want to increase that (but make sure you use 1.3.4 or later of the driver).

Related

GuzzleHttp\Exception\ConnectException: cURL error 28 when using Google Cloud Speech PHP API

Following Google's instructions to the letter.
This is what I get:
Fatal error: Uncaught GuzzleHttp\Exception\ConnectException: cURL error 28: Connection timed out after 500 milliseconds (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in C:\xampp\htdocs\ModernMT\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:207 Stack trace: #0 C:\xampp\htdocs\ModernMT\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(162): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 C:\xampp\htdocs\ModernMT\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(109): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #2 C:\xampp\htdocs\ModernMT\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php(45): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #3 C:\xampp\htdocs\ModernMT\vendor\guzzlehttp\guzzle\src\Handler\Proxy.php(30): GuzzleH in C:\xampp\htdocs\ModernMT\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 207
This happens right after:
# Instantiates a client
$client = new SpeechClient();
Straight from the developers of Google Cloud:
After investigating a bit further, it looks like this is a bug in the google/auth dependency. We just merged a fix, and it should be tagged by the end of the day. You can wait for that (watch this page for v1.11.1), or you could require guzzlehttp/guzzle at ^6.5 to get it working right now. Sorry for the trouble, and thanks for bringing it to our attention!

Tikiwiki 16.2 Error while registering new user

I did a fresh install of 16.2 and when I try to register a new user I get the error below. I've re-extracted the zip and reinstalled the database, but I get the same error.
Tikiwiki is in a public_html/tiki folder and I have made no adjustments to it.
Any help would be appreciated.
Here's the error:
Fatal error: Uncaught exception 'Zend\Math\Exception\RuntimeException' with message 'The RandomLib fallback pseudorandom generator is not installed. Please install it to support secure random numbers' in /home/ghsfhaco/public_html/tiki/vendor/zendframework/zend-math/src/Rand.php:75 Stack trace: #0 /home/ghsfhaco/public_html/tiki/vendor/zendframework/zend-math/src/Rand.php(60): Zend\Math\Rand
getAlternativeGenerator() #1 /home/ghsfhaco/public_html/tiki/vendor/zendframework/zend-captcha/src/AbstractWord.php(354): Zend\Math\Rand
getBytes(32) #2 /home/ghsfhaco/public_html/tiki/vendor/zendframework/zend-captcha/src/AbstractWord.php(340): Zend\Captcha\AbstractWord->generateRandomId() #3 /home/ghsfhaco/public_html/tiki/vendor/zendframework/zend-captcha/src/Image.php(447): Zend\Captcha\AbstractWord->generate() #4 /home/ghsfhaco/public_html/tiki/lib/captcha/captchalib.php(150): Zend\Captcha\Image->generate() #5 /home/ghsfhaco/public_html/tiki/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(171) : eval()'d c in /home/ghsfhaco/public_html/tiki/vendor/zendframework/zend-math/src/Rand.php on line 75
This also caught us out the other day and it's due to an older version of PHP 5 which hasn't got the mcrypt extension enabled, and we fixed it recently, so there are a few options for you I think:
Upgrade to php 7 (probably not an option unless it's your own server)
Enable php-mcrypt for you php (also probably not possible)
Try again with a recent "daily build" 16.x tarball from dev.tiki.org
Or enable one of the other CAPTCHA methods on Control panels->Security->Spam Protection, such as ReCaptcha or CAPTCHA Questions
HTH

Zend Framework Migration to Live Server

Pardon me guys, I am new to ZF. I need to move my codes from MAMP production server to LAMP Live Server.
When I am working on localhost with the codes are all working fine. However when I upload it to live server, 60% of the modules reflect this error.
Fatal error: Uncaught exception 'Zend_View_Exception' with message
'script 'layout.phtml' not found in path
(/home/lifeoppc/public_html/application/layouts/:/home/lifeoppc/public_html/application/modules/default/views/scripts/:./views/scripts/)'
in /home/lifeoppc/public_html/public/Zend/View/Abstract.php:988 Stack
trace: #0
/home/lifeoppc/public_html/public/Zend/View/Abstract.php(884):
Zend_View_Abstract->_script('layout.phtml') #1
/home/lifeoppc/public_html/public/Zend/Layout.php(796):
Zend_View_Abstract->render('layout.phtml') #2
/home/lifeoppc/public_html/public/Zend/Layout/Controller/Plugin/Layout.php(143):
Zend_Layout->render() #3
/home/lifeoppc/public_html/public/Zend/Controller/Plugin/Broker.php(333):
Zend_Layout_Controller_Plugin_Layout->postDispatch(Object(Zend_Controller_Request_Http))
#4 /home/lifeoppc/public_html/public/Zend/Controller/Front.php(965): Zend_Controller_Plugin_Broker->postDispatch(Object(Zend_Controller_Request_Http))
#5 /home/lifeoppc/public_html/public/Zend/Application/Bootstrap/Bootstrap.php(9
in /home/lifeoppc/public_html/public/Zend/Controller/Plugin/Broker.php
on line 336
I really really need help! Site is going live on Monday and I am really desperate right now =(
Search for file layout.phtml inside your project and then copy paste it inside directory
/home/lifeoppc/public_html/application/layouts/

New Server: Zend_Session_Exception "session has already been started" http to https & vice versa

I'm trying to move a website to a new host (MediaTemple.)
When you stick to http, or https everything is fine. When going from http->https or https->http you get the error.
Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'session has already been started by session.auto-start or session_start()'
in /var/www/vhosts/FakeSite.com/httpdocs/library/Zend/Session.php:462
Stack trace:
#0 /var/www/vhosts/FakeSite.com/httpdocs/library/Zend/Session/Namespace.php(143): Zend_Session::start(true)
#1 /var/www/vhosts/FakeSite.com/httpdocs/library/Zend/Auth/Storage/Session.php(87): Zend_Session_Namespace->__construct('Zend_Auth')
#2 /var/www/vhosts/FakeSite.com/httpdocs/library/Zend/Auth.php(91): Zend_Auth_Storage_Session->__construct()
#3 /var/www/vhosts/FakeSite.com/httpdocs/library/Zend/Auth.php(141): Zend_Auth->getStorage()
#4 /var/www/vhosts/FakeSite.com/httpdocs/application/layouts/layout.phtml(12): Zend_Auth->hasIdentity()
#5 /var/www/vhosts/FakeSite.com/httpdocs/library/Zend/View.php(108): include('/var/www/vhosts...')
#6 /var/www/vhosts/FakeSite.com/httpdocs/library/Zend/View/Abstract.php(831): Zend_View->_run('/var/www/vhosts...')
#7 /var/www/vh in /var/www/vhosts/FakeSite.com/httpdocs/library/Zend/Session.php on line 462
Session path is writable, and seems to work fine if you stick to one protocol. There are no session_start() calls, and session.auto-start is 0.
Code is running on 3 other servers fine. It must be a configuration issue, but I haven't been able to find it
Sure looks like the server is configured with session.auto_start = 1.
So, maybe add to configs/application.ini:
phpSettings.session.auto_start = 0
I think you have a plugin(or other library), which calls session_start() function
I had the same problem, when tried to create facebook resource
I figured finally it out.
Problem was that PHP on http was running as an Apache module, and PHP on https was running as a FastCGI module.
I assume those run as different users on MediaTemple or something. The session would get created by one, and not be able to be read by the other because another user owned the file.

Zend frame work Database connection and configuration

I am very new to zend frame work , I want to do some updation work in one project that already done by other programmers, now iam trying to setting up this project in my local server (I am using xamp), i have created the database in phpmyadmin, but while running this project i got the following error....
"Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'SQLSTATE[28000] [1045] Access denied for user 'numberfo_admin'#'localhost' (using password: NO)' in C:\xampp\php\PEAR\Zend\Db\Adapter\Pdo\Abstract.php:144 Stack trace: #0 C:\xampp\php\PEAR\Zend\Db\Adapter\Pdo\Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect() #1 C:\xampp\php\PEAR\Zend\Db\Adapter\Abstract.php(832): Zend_Db_Adapter_Pdo_Mysql->_connect() #2 C:\xampp\php\PEAR\Zend\Db\Adapter\Abstract.php(902): Zend_Db_Adapter_Abstract->quote(1257218565, NULL) #3 C:\xampp\htdocs\NFL_021\library\Utils\session_handling.php(16): Zend_Db_Adapter_Abstract->quoteInto('last_login_date...', 1257218565) #4 C:\xampp\htdocs\NFL_021\application\controllers\IndexController.php(16): require_once('C:\xampp\htdocs...') #5 C:\xampp\php\PEAR\Zend\Controller\Action.php(513): IndexController->indexAction() #6 C:\xampp\php\PEAR\Zend\Controller\Dispatcher\Standard.php(289): Zend_Controller_Action->dispatch('indexAction') #7 C:\xampp\php\PEAR\Zend\Controller\Front.php(946 in C:\xampp\php\PEAR\Zend\Db\Adapter\Pdo\Abstract.php on line 144"
Plsss any one help me to fix this error........
It looks like you either have incorrect permissions set up with MySql or you're trying to access the database using wrong credentials from Zend Framework. Verify that you can log in to the database with the credentials you're trying to use (via phpMyAdmin). Also verify that in Zend Framework you're using the credentials that indeed have access to the database in question.
Set password for Mysql user (it my be «root» or some other).
Then edit Zend configuration file such as application.ini