brefphp / extra-php-extensions

Community-maintained extra PHP extensions usable in AWS Lambda with the Bref PHP runtimes.
https://bref.sh/docs/environment/php.html#extra-extensions
213 stars 110 forks source link

Sqlsvr issue - TCP Provider: Error code 0x2746 #502

Closed mattcollinsep171 closed 9 months ago

mattcollinsep171 commented 11 months ago

I'm currently trying to get a lambda to talk to a MSSQL DB and have been running it both locally (through docker) and also on the lambda directly. I have used the extras layers - 'bref/extra-sqlsrv-php-82:1'. But I'm always getting the following error.

[info] User Deprecated: Relying on a fallback connection used to determine the database platform while connecting to a non-existing database is deprecated. Either use an existing database name in connection parameters or omit the database name if the platform and the server configuration allow that. (Connection.php:458 called by Connection.php:410, https://github.com/doctrine/dbal/pull/5707, package doctrine/dbal)
Doctrine\DBAL\Exception\DriverException: An exception occurred in the driver: SQLSTATE[08001]: [unixODBC][Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746
Stack trace:
#0 /var/task/vendor/doctrine/dbal/src/Connection.php(1938): Doctrine\DBAL\Driver\API\SQLSrv\ExceptionConverter->convert(Object(Doctrine\DBAL\Driver\PDO\Exception), NULL)
#1 /var/task/vendor/doctrine/dbal/src/Connection.php(1886): Doctrine\DBAL\Connection->handleDriverException(Object(Doctrine\DBAL\Driver\PDO\Exception), NULL)
#2 /var/task/vendor/doctrine/dbal/src/Connection.php(379): Doctrine\DBAL\Connection->convertException(Object(Doctrine\DBAL\Driver\PDO\Exception))
#3 /var/task/vendor/doctrine/dbal/src/Connection.php(452): Doctrine\DBAL\Connection->connect()
#4 /var/task/vendor/doctrine/dbal/src/Connection.php(410): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#5 /var/task/vendor/doctrine/dbal/src/Connection.php(317): Doctrine\DBAL\Connection->detectDatabasePlatform()
#6 /var/task/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php(867): Doctrine\DBAL\Connection->getDatabasePlatform()
#7 /var/task/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php(625): Doctrine\ORM\Mapping\ClassMetadataFactory->getTargetPlatform()
#8 /var/task/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php(156): Doctrine\ORM\Mapping\ClassMetadataFactory->completeIdGeneratorMapping(Object(Doctrine\ORM\Mapping\ClassMetadata))

I have passed into the environmental variables - 'ODBCSYSINI: /opt/microsoft/conf/'

Any help with this would be gratefully received, as I feel like I'm getting nowhere.

Nyholm commented 9 months ago

I dont think this is an issue with the extension at all.

Either use an existing database name in connection parameters or omit the database name if the platform and the server configuration allow that. (Connection.php:458 called by Connection.php:410, https://github.com/doctrine/dbal/pull/5707, package doctrine/dbal)

You just have not configured your database connection properly. Maybe pass a DATABASE_URL directly to doctrine instead of using values on the disk.