FraunhoferIOSB / FROST-Server

A Complete Server implementation of the OGC SensorThings API
https://fraunhoferiosb.github.io/FROST-Server/
GNU Lesser General Public License v3.0
198 stars 74 forks source link

DB Connections (db address only) #639

Open kkehl-usgs opened 2 years ago

kkehl-usgs commented 2 years ago

Hi,

We'd like to be able to swap databases without redeploying FROST server. For other servers we typically create a CNAME record and supply that as the database address to the server, then we can modify the CNAME record as desired.

However, it seems like this would not be doable with FROST server since we are using org.postgresql.Driver and it seems like it cannot resolve:

jdbc:postgresql://:/sensorthings

Is it possible to add the ability to just configure a database address and database port and connect that way? Thanks!

hylkevds commented 2 years ago

I don't really see how a piece of software is supposed to make a connection to :, since that contains no hostname nor a port number. How is that supposed to be resolved to an IP address?

You'd need at least a name and port number in there, hence the default jdbc:postgresql://database:5432/sensorthings that makes the driver resolve the name database to an IP address, and connect to that on port 5432.

Is the actual problem that the name is only resolved once, and when the name is changed in the DNS server, the name is not resolved again when the connection is lost?

kkehl-usgs commented 2 years ago

sorry I don't know why that was blank, I think I had hostname and ports in brackets, it must have been stripped out. What I mean is just to provide the hostname, port, username, and password and that's it.

The problem is that frost server won't connect when the 'database' portion is a CNAME record, although I can connect to the database just fine with a CNAME record when I use pg_admin. FROST Server connects fine when I use an RDS endpoint, but not when I use a CNAME record that redirects to an RDS endpoint. So somehow passing the jdbc string with an embedded CNAME record doesn't resolve (presumably in the org.postgresgrl.Driver). Thanks!

And trying again on the formatting, here is what doesn't work when I put it into a FROST Server variable:

jdbc:postgresql://CNAME_record:port/sensorthings

hylkevds commented 2 years ago

I don't see what that wouldn't work. Do any other Java programs have an issue with CNAMEs? You might want to ask on the PGJDBC github, or break out WireShark to see what's actually happening.