ACE with Postgres DB for production and development

Hi
I am running ACE with a Postgres DB. I have noticed some issues when running in development mode, however the production config works when deployed to a remote PM2 instance (I have verified the record is created in the AddonSettings table).

When running the local dev instance via ngrok I get the following error in the console:

Failed to register with host [redacted]
The app host did not respond when we tried to contact it at “https://1f8388d7.ngrok.io//installed” during installation (the attempt timed out). Please try again later or contact the app vendor.

Note that it also works when I use the default sqlite/memory DB.

My ‘store’ object in config.json looks like this (development):

“store”: {
“adapter”: “sequelize”,
“type”: “postgres”,
“database”: “app_d”,
“url”: “postgres://app_d_user:password@ip_address:5432/app_d”
}

In production (working):

“store”: {
“adapter”: “sequelize”,
“type”: “postgres”,
“database”: “app”,
“url”: “postgres://app_user:password@ip_address:5432/app”
}

I’ve opened access to port 5432 on the DB, and both databases / users are present.
Any ideas on this one?

Hi @stevemac are you watching node logs while the /installed end point is hit, do you get any errors? Is your ngrok url registered in the app descriptor? Also, seems you have an extra / in the ngrok installed path.

Hi @biro
The only error I can see is the “Failed to register host” error above.
The DB is on a seperate server and this is in the url string. Not sure about the ngrok URL being registered in the app descriptor? The baseUrl in atlassian-connect.json looks like this
“baseUrl”: “{{localBaseUrl}}”,

Installed routes look like:

“lifecycle”: {
“installed”: “/installed”,
“uninstalled”: “/uninstalled”
},

I do not have a ‘/installed’ route defined, as I believe it’s handled internally by ACE.

I believe the “//” in the output is misleading. It looks like something in the “/installed” route processing is breaking down due to the database config in config.json.
From adding some logging, I can see the the post handler in lib/index.js is being invoked, but the verifyInstallation middleware function is failing somewhere.
There is a call to addon.settings.get(‘clientInfo’, clientKey) in lib/middleware/registration/verify-installation.js which is not returning a response. I presume this is the call to get the client details in the DB. So my take on it at this point is that the config for the Postgres DB in config.json is incorrect somehow.

Got it working by running Postgres locally with 127.0.0.1 as the host.
It would seem that development store config must point to a local DB.

2 Likes

Ah, it makes sense it uses a local DB @stevemac. We containerised our apps so we let Docker handle the db distribution. I’m glad you figured it out. If you’re interested, here’s our opensource boilerplate using ACE, Docker-compose, Apollo GraphQL and Sequelize: https://www.jexo.io/boilerplate

1 Like