Keycloak wait for database connection in standalone mode - wildfly

I am running Keycloak on the standalone configuration on wildfly. As database I use MSSQL on a different server than Keycloak. The problem now is that on similar startup the SQL Server needs longer to boot. That causes the Keycloak Service to crash because Wildfly couldn`t connect to the database till deployment.
I already added
<validation>
<check-valid-connection-sql>select 1</check-valid-connection-sql>
<background-validation>true</background-validation>
<background-validation-millis>10000</background-validation-millis>
</validation>
to the Datasource. This helped to reconnect if Keycloak is already running and the Database reboots but not on startup.
Is it possible that the Wildfly Server retries to connect to the Database when deploying Keycloak or is there another workaround?

Related

connecting springboot application running locally to db instance running on aws VM instance

I have written a set of APIs using springboot framework. Locally its working fine. But now I am trying to test it with the postgresql database running on ec2 instance on aws.
NOTE: I am not using amazon RDS services, I have created an ec2 instance and installed postgres and configured database there.
I can see this exception being thrown when I am running my springboot application locally.
org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:297)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:211)
This is the config from application.properties for one of the db
spring.xyz.datasource.jdbc-url=jdbc:postgresql://xyz.com:5432/xyz_db
spring.xyz.datasource.username=xyz
spring.xyz.datasource.password=xyz123
Am I not being able to connect because of the EC2 instance security configs ? How can I change that ?
Also it will be helpful if someone can tell me how can I make aws ec2 instance to accept the connection from only one VM ?
regarding Postgress connection-
add below rule to security group of Ec2 instance , on which you have installed postGress
Allow inbound traffic to postgress port from 0.0.0.0/0 and test. ( protocol- TCP, port - 5432, IP - 0.0.0.0/0)
regarding allow from only one VM
add security group rule to your Ec2 instance
Allow inbound traffic from your VM IP only

Error no pg_hba.conf entry for host when using PG client, but not when connecting with psql?

I'm pointing my application from one PG cluster to another (changing the team that manages the PG cluster), and I'm getting connection errors when trying to connect with a language binding for javascript:
no pg_hba.conf entry for host xxx.x.x.x, user "blah", database "blah", SSL off
I'm led to believe that this is a pg_hba.conf configuration error, but I can connect to the cluster with psql, from the same machine, with the same credentials.
psql: 9.5.7,
PG cluster 10.5
Client: pg-promise 9.3.3
How can this be possible? Is this still definitely an issue with how pg_hba.conf is set up or is there something wrong with how I configured my client? This is not the first time I've used it, I've been connecting to a PG cluster v. 9.5.7 for the last couple of years.
The issue was that the new cluster is using SSL for the connection. When I connected to the old cluster, there was no SSL, so the connection worked with my current config, but when switching to the new cluster I had to specify that SSL was being used.
https://github.com/vitaly-t/pg-promise/wiki/Connection-Syntax

Unable to obtain Jdbc connection from DataSource, SSL error: Connection reset

Facing connection issue while connecting to postgresql pod running in OpenShift environment. Details are as below
URL: jdbc:postgresql://XXX:5432/YYY?sslmode=require
Flyway 4.2.0 by Boxfuse
ERROR:
Unable to obtain Jdbc connection from DataSource
(jdbc:postgresql://XXX:5432/YYY?sslmode=require)
for user 'ABC': SSL error: Connection reset
Just wanted to confirm if I need to add certificates to make the connection work?
Please advise.
We have fixed this issue by upgrading flyway version to 6.0.7 and postgres driver version to 42.2.8.
The below URL string worked
jdbc:postgresql://XXX:5432/YYY?sslmode=require
Thank you all.
I would recommend checking the networking setup of your application which basically means have a look at:
The route (does a DNS record exist for your hostname? Is your route pointing to the correct service and service port?)
The service (is the target port the port your postgresql is listening on?)
The deploymentconfig (did you expose the right port?)
The postgresql (it needs to listen on 0.0.0.0 instead of localhost/127.0.0.1 -> all interfaces (a common mistake))

How to connect apollo server to a remote mongo instance of an application deployed with mup

So I have application A and Application B, I want to connect to the mongo instance of application B (through apollo server) which is deployed with mup in another server. By default, you cannot connect to the mongo instance of an application deployed with mup from outside. I tried setting bind_ip=0.0.0.0 in mongo config and set the necessary users and passwords but no luck.
The connections work find if all applications are running in the same server.

general sql error

I have created an application in delphi and backend is postgres when i run the application i get the following error
general sql error.could not connect to the server;no
connection could be made because the target machine actively refused
it.[127.0.0.1:1:5433 alias resumep
I uninstalled it and installed it again but it didnt work.Even i changed the port number while installing .
I changed the password and installed again but its giving same error
what is the solution to this problem?
The database cluster of a standard PostgreSQL installation is listening on port 5432. (You can, of course, set up additional db clusters on different ports or configure your database cluster to listen on any other port.)
Any particular reason you try 5433? This is probably the cause of your problem.
If no server is listening on port 5433, the connection is simply not possible.