Reputation: 1
I am trying to connect my NestJS application to Oracle Autonomous Database using TypeORM. I have configured everything in TypeORM, but I am facing issues.
I tried to set up the app.module.ts
with the necessary settings, but it doesn't work.
Here is my app.module.ts
configuration:
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true, envFilePath: '../../.env' }),
TypeOrmModule.forRoot({
type: 'oracle',
host: 'adb.sa-saopaulo-1.oraclecloud.com',
sid: '<ssid>_high.adb.oraclecloud.com',
database: '<db_name>',
username: '<username>',
password: '<password>',
connectString: '<database>_high',
autoLoadEntities: true,
synchronize: true,
logging: true,
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
My .env
has the TNS_ADMIN
variable set like this:
// Other .env variables that are being used directly
TNS_ADMIN=../../wallet/Wallet_<database>
Basically, the error I get is the following:
[Nest] 58658 - 22/11/2024, 15:42:56 ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)...
Error: NJS-511: connection to listener at host <ip addrs> port 1522 was refused. (CONNECTION_ID=...)
Cause: ORA-12506
at Object.throwErr (...node_modules/oracledb/lib/errors.js:693:10)
at NetworkSession.connect2 (/.../node_modules/oracledb/lib/thin/sqlnet/networkSession.js:244:18)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async NetworkSession.connect1 (.../node_modules/oracledb/lib/thin/sqlnet/networkSession.js:320:23)
at async NetworkSession.connect (.../node_modules/oracledb/lib/thin/sqlnet/networkSession.js:542:5)
at async ThinConnectionImpl.connect (.../node_modules/oracledb/lib/thin/connection.js:775:5)
at async ThinPoolImpl.bgThreadFunc (.../node_modules/oracledb/lib/thin/pool.js:455:11)
^C
The problem doesn't seem to be related to ACL filtering because I can connect to the server using the SQL Developer client, and I have accepted my own IP address in the OCI configuration.
oracle developer client connection
I tried to connect my NestJS application to Oracle Autonomous Database using TypeORM and Oracle Wallet. I configured the app.module.ts file with the necessary connection details and set the TNS_ADMIN variable in my .env file to point to the wallet directory. I expected the connection to work, similar to how it works in Oracle SQL Developer, with SSL/TLS configuration for secure communication.
However, I am receiving the NJS-511: connection to listener was refused error with ORA-12506, indicating that the connection to the database is being blocked or not established correctly.
Upvotes: 0
Views: 89