[Python] Why is my flask application taking soo long to connect to the Oracle database from...

Discussão em 'Python' iniciado por Stack, Maio 11, 2025.

  1. Stack

    Stack Membro Participativo

    So, i have been stuck with the connection timeouts happening from the PCF server. I am using oracledb.connect() and i'm fetching the role from the database.

    Until I restart the application in PCF it does not get connected at all. This is my connection function:

    def connect(self):
    self.close_connection()
    """Establish a direct connection."""
    try:
    self.connection = oracledb.connect(
    protocol=self.protocol,
    host=self.host,
    port=self.port,
    service_name=self.service_name,
    ssl_server_cert_dn=self.ssl_server_cert_dn,
    user=self.username,
    password=self.password
    )
    print("- Connected to the database.")
    except oracledb.DatabaseError as e:
    error, = e.args
    raise Exception(f"Database connection failed. Error code: {error.code}, Error message: {error.message}")

    except Exception as e:
    print(f"An unexpected error occurred: {str(e)}")
    sys.exit(1)


    Whenever the application is left idle for sometime and when i try to connect it's giving me 502 bad gateway error

    But from local it is fetching it all fine.

    Continue reading...

Compartilhe esta Página