I am using MongoDB Atlas cloud services with my Symfony 3 application and I am having lots of warnings in my PHP logs saying MongoClient::__construct(): SSL: Connection reset by peer. Even though I have warnings some times, I can connect successfully and read/write to the server.
I use Doctrine ODM which uses MongoClient for connecting to the server. I have configured the replicaSet according to MongoDB Atlas configuration.
When I look at MongoDB logs, I do not see any strange thing that appears to be linked to my issue.
Here is my connection string: mongodb://<USERNAME>:<PASSWORD>#datalake-shard-00-00-lnres.mongodb.net:27017,datalake-shard-00-01-lnres.mongodb.net:27017,datalake-shard-00-02-lnres.mongodb.net:27017/test?ssl=true&replicaSet=DataLake-shard-0&authSource=admin
Here is my Doctrine ODM config
doctrine_mongodb:
connections:
default:
server: "mongodb://<USERNAME>:<PASSWORD>#datalake-shard-00-00-lnres.mongodb.net:27017,datalake-shard-00-01-lnres.mongodb.net:27017,datalake-shard-00-02-lnres.mongodb.net:27017/test?ssl=true&replicaSet=DataLake-shard-0&authSource=admin"
options:
authMechanism: SCRAM-SHA-1
authSource: admin
connect: true
ssl: true
password: "<PASSWORD>"
username: "<USERNAME>"
readPreference: secondaryPreferred
replicaSet: "DataLake-shard-0"
default_database: "test"
document_managers:
default:
auto_mapping: true
retry_connect: 4
retry_query: 4
Related
Hey guys so im trying to connect to my databse that's already created in postgresql (I'm using PGAdmin4 for the user interface of postgresql).
I'm on Symfony CLI version v4.16.3 get three different Timeout.
In details i have a .env file that take the my database url :
DATABASE_URL=postgresql://root:password#127.0.0.1:35583/nd2d?serverVersion=12.3
My doctrice.yaml is set up like this :
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
I had issue but found a way to fix they were related to pdo drivers for postgresql.
but after i launch the command bin/console make:migration i get those 3 errors:
In AbstractPostgreSQLDriver.php line 73:
An exception occurred in driver: SQLSTATE[08006] [7] timeout expired
In PDOConnection.php line 31:
SQLSTATE[08006] [7] timeout expired
In PDOConnection.php line 27:
SQLSTATE[08006] [7] timeout expired
I avoided working on heavyn program with PHP or any framework related to it but this time i don't have a choice, soo much configuration i cant take it anymore, been on this for soo many hours now. What am i missing.
Thank you :)
Error came from listening on the wrong port, i was listening to the port 35583, which is the port that PgAdmin is showed on the web browse.
DATABASE_URL=postgresql://root:password#127.0.0.1:35583/nd2d?serverVersion=12.3
The port i should have been listening to is the default postgresql port of 5432
I have two MongoDB instances - one slave and one master. There is an Arbiter too.
Basically the setup is the following:
(Image Source: https://docs.mongodb.com/manual/replication/)
In my Symfony application, in config.yml I have this for MongoDB:
# Mongo DB
doctrine_mongodb:
connections:
default:
server: %database_mongodb_access%
options: {}
default_database: %database_mongodb_name%
document_managers:
default:
auto_mapping: true
where %database_mongodb_access% is 'mongodb://mongo:27017'.
How to configure my Symfony/Doctrine application to automatically failover to the slave MongoDB instance if the primary fails, so the application continues working?
It is not clear to me from the docs:
http://symfony.com/doc/master/bundles/DoctrineMongoDBBundle/config.html
It is possible to connect to several mongodb servers on one connection if you are using a replica set by listing all of the servers within the connection string as a comma separated list.
doctrine_mongodb:
# ...
connections:
default:
server: "mongodb://mongodb-01:27017,mongodb-02:27017,mongodb-03:27017"
http://symfony.com/doc/master/bundles/DoctrineMongoDBBundle/config.html#connecting-to-a-pool-of-mongodb-servers-on-1-connection
And check the retry mechanism for failover :
http://symfony.com/doc/master/bundles/DoctrineMongoDBBundle/config.html#retrying-connections-and-queries
I'm testing Memcached on my Symfony2 application
I set it to cache doctrine's queries, results and metadata:
orm:
entity_managers:
default:
metadata_cache_driver:
type: service
id: doctrine.cache.memcache2
query_cache_driver:
type: service
id: doctrine.cache.memcache2
result_cache_driver:
type: service
id: doctrine.cache.memcache2
services:
memcache:
class: Memcache
calls:
- [ addserver, [ 'localhost', 11211 ]]
doctrine.cache.memcache2:
class: Doctrine\Common\Cache\MemcacheCache
calls:
- [setMemcache, [#memcache]]
Until now, everything works fine.
I was wondering how does doctrine behaves if the Memcached server goes down. As far as I could see, the application breaks. In dev mode I get the following message:
Notice: MemcachePool::get(): Server localhost (tcp 11211, udp 0) failed with: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
(10060)
500 Internal Server Error - ContextErrorException
In production mode I'm also presented with an http 500.
Is there a way to tell doctrine to bypass/ignore the Memcached server and go directly to the database, instead of returning 500s?
You can use The Second Level Cache available in doctrine/orm 2.5
see:
http://doctrine-orm.readthedocs.org/projects/doctrine-orm/en/latest/reference/second-level-cache.html
The idea to keep you default options for orm and add a memcache as second level cache:
orm:
entity_managers:
default:
auto_mapping: true
second_level_cache:
region_cache_driver:
type: service
id: doctrine.cache.memcache2
enabled: true
regions:
region_name:
cache_driver:
type: service
id: doctrine.cache.memcache2
When turned on, entities will be first searched in cache and if they are not found, a database query will be fired and then the entity result will be stored in a cache provider.
I am trying to connect Symfony 2.8 to Microsoft SQL Server 2012 by using sqlsrv extension (no pdo sqlsrv, because for php7 - which I am using - there is currently only non pdo).
Trying to run cache clear or access the site in browser results in
"PDO::__construct(): MySQL server has gone away".
When I run the doctrine schema update command, everything works fine and the tables are being generated. Does anyone know how to fix the error? (I don't even know why it says Mysql server gone away when I try to connect on microsoft sql..)
Config:
# Doctrine Configuration
doctrine:
dbal:
default_connection: default
connections:
default:
driver: sqlsrv
host: testhost
dbname: testdb
user: testuser
password: testpw
mapping_types:
timestamp: string
I am looking for a solution since Friday but was not able to find one. I tried to select some entries from a seperate (non symfony) php skript, and there I got the results and no timeout. Why is Symfony / Doctrine giving me this strange error?
you can try to launch this command for doctrine :
php app/console doctrine:cache:clear-metadata
php app/console doctrine:cache:clear-query
php app/console doctrine:cache:clear-result
Also perhaps upgrade and downgrade your doctrine bundle for restore a correct and initial version of bundle for your project.
I'm having an issue with Doctrine2 that seems like a bug but I can't find anyone else on Google with the same problem. I'm hoping somewhere here has experienced this problem and knows how to solve it.
Basically I'm trying to connect to a DB2 database. I prefer to use the ibm_db2 client as it's supposed to be better and faster (than PDO_IBM or PDO_ODBC). I've installed the client and tested it. Everything seems to work there. But when I use Doctrine I get the following error:
Notice: Undefined index: protocol in
...[my folders].../vendor/doctrine-dbal/lib/Doctrine/DBAL/Driver/
IBMDB2/DB2Driver.php line 54
So in that file it's looking for $params['protocol'] which seems to have no defaults. So in config.yml I tried this:
# Doctrine Configuration
doctrine:
dbal:
default_connection: default
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
protocol: TCPIP
But when I do that it complains that protocol is an undefined configuration option (and looking through the DependencyInjection stuff it doesn't appear anywhere in there.)
However: if I hard-code TCPIP into the Driver file where the error occurs ... it all works. This is undesirable since it involves changing the vendor supplied file. Has anyone found a way to properly specify the protocol in configuration?
Eventually you're going to run into licensing issues using ibm_db2 as noted here. PDO or ODBC are going to be your only free ways to go. IBM requires DB Connect to use ibm_db2 db2_connect() stuff.