Skip to main content
Version: 2.2.0

FAQ

This section is meant to address and document common questions, mistakes, errors, and pitfalls that people might run into.

Append context path prefix to RTUS-SEH URL

In the situation where you need the endpoints of the RTUS-SEH need to be prefixed with a specific context path, you can do so by added the following environment variable:

server.servlet.context-path=/context-path

where context-path is the prefix to append to the RTUS-SEH endpoint URL.

For example, when the following is added to RTUS-SEH environment variable:

server.servlet.context-path=/API

the URL to subscribe for the MAP update will be:

http://rtus-seh.127.0.0.1.nip.io/API/tenants/123456/maps/gisMap

instead of

http://rtus-seh.127.0.0.1.nip.io/tenants/123456/maps/gisMap

RDS Failover Connection Issues

Problem

When AWS RDS performs a failover (e.g., during maintenance or instance failure), the application fails to connect to the new primary instance with errors like:

org.postgresql.util.PSQLException: This connection has been closed.
HikariPool-1 - Connection is not available, request timed out after 30036ms
Could not open JPA EntityManager for transaction

Root Cause

After RDS failover, several factors prevent the application from reconnecting:

  1. Stale connection pool: HikariCP holds connections to the old primary that are now closed
  2. JVM DNS caching: Java caches DNS lookups, so it keeps resolving to the old IP address
  3. Missing JDBC failover parameters: The PostgreSQL driver doesn't know to reconnect to the new primary

Solution

Apply the following configuration changes:

1. JDBC URL Parameters

Add failover-friendly parameters to your DATABASE_URL:

jdbc:postgresql://CLUSTER_ENDPOINT:5432/db?currentSchema=schema&targetServerType=primary&tcpKeepAlive=true&connectTimeout=10&socketTimeout=30
ParameterValuePurpose
targetServerTypeprimaryEnsures connection only to the writer instance
tcpKeepAlivetrueDetects dead connections at TCP level
connectTimeout10Fails fast (10 seconds) when host is unreachable
socketTimeout30Times out stale socket operations

2. HikariCP Connection Pool Settings

Add to application.properties:

spring.datasource.hikari.connection-test-query=SELECT 1
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.validation-timeout=2000
spring.datasource.hikari.connection-timeout=5000
PropertyValuePurpose
connection-test-querySELECT 1Validates connections before use
max-lifetime1800000 (30 min)Recycles connections periodically
validation-timeout2000 (2 sec)Fast validation check
connection-timeout5000 (5 sec)Fails fast if pool is exhausted

3. JVM DNS Cache Settings

Set the JAVA_TOOL_OPTIONS environment variable:

JAVA_TOOL_OPTIONS=-Dsun.net.inetaddr.ttl=60 -Dsun.net.inetaddr.negative.ttl=10
PropertyValuePurpose
sun.net.inetaddr.ttl60Caches successful DNS lookups for 60 seconds
sun.net.inetaddr.negative.ttl10Caches failed DNS lookups for 10 seconds

For Kubernetes deployments, add to your container spec:

env:
- name: JAVA_TOOL_OPTIONS
value: "-Dsun.net.inetaddr.ttl=60 -Dsun.net.inetaddr.negative.ttl=10"

Summary

With these settings, the application will:

  • Detect closed connections and remove them from the pool
  • Resolve the new primary IP within 60 seconds of failover
  • Automatically reconnect to the new primary instance