keycloak-x - unable to modify mssql/SQLServer port to anything other than 1433
See original GitHub issueDescribe the bug
Setting the KC_DB_URL_PORT environment variable does not work. The default of 1433 is retained when keycloak attempts to connect to the database.
Version
17.0.1
Expected behavior
Specifying the environment property KC_DB_URL_PORT should be honored. Keycloak should try to establish it’s database connections using that port.
Actual behavior
Here is the error that shows up at startup:
2022-04-12 13:46:09,475 WARN [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator] (JPA Startup Thread: keycloak-default) HHH000342: Could not obtain connection to query metadata: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host my-mssql.db, port 1433 has failed. Error: "connect timed out. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.". at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:234) at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:285) at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2431) at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:656) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2440) at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2103) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1950) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1162) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:735) at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:210) at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:513) at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:494) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:75) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1126) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829)
How to Reproduce?
Here is the relevant section of the chart yaml’s env I am using to specify the database properties.
env:
- name: KC_DB
value: mssql
- name: KC_DB_URL_HOST
- value: my-mssql.db
- name: KC_DB_URL_PORT
value: "1443"
- name: KC_DB_DATABASE
value: keycloak
- name: KC_TRANSACTION_XA_ENABLED
value: "false"
....
Start the container as such
command:
- "/opt/keycloak/bin/kc.sh"
- "--verbose"
- "start"
- "--auto-build"
Anything else?
The dbchecker honors the property just fine. It appears that the port is hardcoded to 1433 in org.keycloak.quarkus.runtime.storage.database.Database. Reviewing that file suggests the problem would be true of other databases…
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
Yeah, I think so. We do have options for host and database. Having an option to set the port should make the config more consistent.
Thanks for the quick turn around