PostgreSQL connection fail - Error 503

Willem5 years ago

I am testing with Traccar 4.3-SNAPSHOT. Everything works just fine (using the default H2 database), even my own Protocol Decoder. Kudos Anton for a great product.

However, when I want to connect to PostgreSQL, it fails. Here is what I have tried (and my configuration - on Ubuntu 18.04 LTS):

tracccar.xml:

    <entry key='database.driver'>org.postgresql.Driver</entry>
    <entry key='database.url'>jdbc:postgresql://127.0.0.1:5432/traccar</entry>
    <entry key='database.user'>postgres</entry>
    <entry key='database.password'>password</entry>

NOTE: password is replaced with the real password for Postgres.

I have confirmed that I do have "postgresql-42.2.5.jar" in the "/opt/traccar/lib" path.
I have confirmed the JAVA_HOME environment variable with "echo $JAVA_HOME", giving me "/usr/lib/jvm/java-11-openjdk-amd64"

I checked the JAVA version with "java -version", giving me:

openjdk version "10.0.2" 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)

Now when I update my "traccar.xml" file with the "postgresql" connection information as shown above, it fails to connect to postgres. Herewith the log information:

2019-04-09 17:02:55  INFO: HikariPool-1 - Starting...
2019-04-09 17:02:56 ERROR: HikariPool-1 - Exception during pool initialization. - SSL error: Received fatal alert: handshake_failure - PSQLException (... < DataManager:139 < *:89 < Context:292 < Main:110 < ...)
2019-04-09 17:02:56 ERROR: Main method error - Failed to initialize pool: SSL error: Received fatal alert: handshake_failure - PoolInitializationException (... < DataManager:139 < *:89 < Context:292 < Main:110 < ...)

This is where it fails, so it seems like an SSL/handshake error which I cannot figure out. And hence the browser also return an Error 503 (because there is no service availble).
So I tried checking with "psql -h localhost traccar", and I got the following back (after entering the password for Postgres):

psql (11.2 (Ubuntu 11.2-1.pgdg18.04+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)

It seems the SSL does work (or am I confusing myself here). Any ideas, please?

Anton Tananaev5 years ago
Willem5 years ago

Thanks a million for that link (above), Anton. Problem resolved. I did as it stated in that thread, and viola, all up and running smoothly.
Thank you once again. Really appreciated.