Problem with connection to external database

69 views
Skip to first unread message

Aleksandr

unread,
Aug 16, 2023, 5:39:36 AM8/16/23
to Tinode General
Hello!
I have faced with a problem. I can't connect to exnternal database using POSTGRES_DSN there is an error
Failed to init DB adapter: failed to connect to host= user= database=: server error (FATAL: no pg_hba.conf entry for host "", user "", database "", no encryption (SQLSTATE 28000))

Can you help ?
Thank you

Gene

unread,
Aug 16, 2023, 5:43:37 AM8/16/23
to Tinode General
Please show your pgsql config section.

Aleksandr

unread,
Aug 16, 2023, 5:51:52 AM8/16/23
to Tinode General
I'm using RDS postgres
Access to database is allowed, I have checked it from another container
connecting by using this command
PGPASSWORD=$PGPASSWORD psql -h host  -U user -d db

Gene

unread,
Aug 16, 2023, 5:54:59 AM8/16/23
to Tinode General
Please open tinode.conf file with your Tinode configuration, find section with your postgres config and copy-paste it here. 

If you don't know what I'm talking about then please read installation instructions.

Aleksandr

unread,
Aug 16, 2023, 6:01:57 AM8/16/23
to Tinode General
I have take template config and recreate it for
"store_config": {
                "uid_key": "",
                "use_adapter": "postgres",
                "adapters": {
                        "postgres": {
                                "User": "rds_user_database_for_connection",
                                "Passwd": "password to db",
                                "Host": "rds_host",
                                "Port": "5432",
                                "DBName": "db_for_chat",
                                // PostgreSQL connection pool settings.
                                // Maximum number of open connections to the database. Zero means unlimited.
                                "max_open_conns": 64,
                                // Maximum number of connections in the idle connection pool. Zero means no idle connections are retained.
                                "max_idle_conns": 64,
                                // Maximum amount of time a connection may be reused. Zero means unlimited.
                                "conn_max_lifetime": 60,
                                // Maximum amount of time waiting for a connection from the pool. Zero means no timeout.
                                "sql_timeout": 10
                        }
                }
        },

Aleksandr

unread,
Aug 16, 2023, 6:07:06 AM8/16/23
to Tinode General
I need to know how to add to this config file, sslmode for connection to database
Is this possible ?

Aleksandr

unread,
Aug 16, 2023, 6:26:30 AM8/16/23
to Tinode General
Another problem
That i have already configured and created database but
it's give me next error
2023/08/16 10:21:04 Database not found. Creating.
If i give a permission for creating Database it's give me next error
2023/08/16 10:23:53 Failure: ERROR: database "tinode" already exists (SQLSTATE 42P04)
Confusing a lot

Gene

unread,
Aug 16, 2023, 6:38:19 AM8/16/23
to Tinode General
If you already created the DB, don't run init-db for the second time.

Aleksandr

unread,
Aug 16, 2023, 6:45:22 AM8/16/23
to Tinode General
How i can turn it off in docker ?

Aleksandr

unread,
Aug 16, 2023, 6:46:56 AM8/16/23
to Tinode General
But i'm runing first time
And database already exist in AWS RDS postgresql i have created it manually

Aleksandr

unread,
Aug 16, 2023, 7:24:38 AM8/16/23
to Tinode General
Resolve issue with init-db;
I have found how to turn it off but

There are problems which i am facing now
I can't connect to database:
1) If i turned off init-db it's generate error
Database not found
2)if i turned on init-db  it's generate error
2023/08/16 10:21:04 Database not found. Creating.
3)If i give a permission for creating Database it's give me next error
2023/08/16 10:23:53 Failure: ERROR: database "tinode" already exists

MyStore config wihout changes
+ i have tried with dsn and have same result
"store_config": {
                "uid_key": "",
                "use_adapter": "postgres",
                "adapters": {
                        "postgres": {
                                "User": "rds_user_database_for_connection",
                                "Passwd": "password to db",
                                "Host": "rds_host",
                                "Port": "5432",
                                "DBName": "db_for_chat",
                                // PostgreSQL connection pool settings.
                                // Maximum number of open connections to the database. Zero means unlimited.
                                "max_open_conns": 64,
                                // Maximum number of connections in the idle connection pool. Zero means no idle connections are retained.
                                "max_idle_conns": 64,
                                // Maximum amount of time a connection may be reused. Zero means unlimited.
                                "conn_max_lifetime": 60,
                                // Maximum amount of time waiting for a connection from the pool. Zero means no timeout.
                                "sql_timeout": 10
                        }
                }
        },

Gene

unread,
Aug 16, 2023, 8:53:23 AM8/16/23
to Tinode General
On Wednesday, August 16, 2023 at 1:46:56 PM UTC+3 Aleksandr wrote:
But i'm runing first time
And database already exist in AWS RDS postgresql i have created it manually

If you created the database then you don't need to run init-db.

Gene

unread,
Aug 16, 2023, 8:55:48 AM8/16/23
to Tinode General
On Wednesday, August 16, 2023 at 2:24:38 PM UTC+3 Aleksandr wrote:
Resolve issue with init-db;
I have found how to turn it off but

There are problems which i am facing now
I can't connect to database:
1) If i turned off init-db it's generate error
Database not found

Yes, you need to run init-db to create the database
 
2)if i turned on init-db  it's generate error
2023/08/16 10:21:04 Database not found. Creating.

That's not an error. It's an info message telling you that init-db is creating the database.
 
3)If i give a permission for creating Database it's give me next error
2023/08/16 10:23:53 Failure: ERROR: database "tinode" already exists

This error message tells you that you are running init-db while the database already exists.

I really do suggest that you follow the instructions. If you want personalized support, consider paying for it

Aleksandr

unread,
Aug 16, 2023, 9:03:06 AM8/16/23
to Tinode General
Why init-db need to create database if i have created it already and give all permissions ?

+ I gave init-db to create database but still have same error, after container rerun with init-db turned off

Gene Sokolov

unread,
Aug 16, 2023, 9:06:30 AM8/16/23
to tin...@googlegroups.com
On Wed, Aug 16, 2023 at 4:03 PM Aleksandr <alexande...@gmail.com> wrote:
Why init-db need to create database if i have created it already and give all permissions ?

 If instead of following instructions you install it in your own way then I have not idea what you need or need not to do. 
--
You received this message because you are subscribed to a topic in the Google Groups "Tinode General" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tinode/F20xurz-1LA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tinode+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tinode/6edacb4d-156e-465d-9d6a-256157155252n%40googlegroups.com.

Aleksandr

unread,
Aug 16, 2023, 9:28:36 AM8/16/23
to Tinode General
Okay can you answer me, is this possible to connect to external database like RDS ?

Aleksandr

unread,
Aug 16, 2023, 9:35:11 AM8/16/23
to Tinode General
One more question, before i go, because i see there is no answer on my questions
Why your docker config dont provide stateful of application ?
Because if you do docker-compose down all containers down, and when you are running again it needs to run init-db. It's very strange, because database already created BY YOUR APPLICATION

Gene

unread,
Aug 16, 2023, 9:44:27 AM8/16/23
to Tinode General
On Wednesday, August 16, 2023 at 4:28:36 PM UTC+3 Aleksandr wrote:
Okay can you answer me, is this possible to connect to external database like RDS ?

I can't see why not.

Gene

unread,
Aug 16, 2023, 9:45:41 AM8/16/23
to Tinode General
On Wednesday, August 16, 2023 at 4:35:11 PM UTC+3 Aleksandr wrote:
One more question, before i go, because i see there is no answer on my questions

I'm so very sorry that you are dissatisfied with a free support for a free product. Would you like to receive a refund?

Aleksandr

unread,
Aug 16, 2023, 10:13:11 AM8/16/23
to Tinode General
Yes, please. Nice Joke of troll

If you write open source, why I don't see that some from community didn't write, i didn't ask help from support. Are you comminity if not why are writing to me ?
Because in github repo i send a question and some of your team send me to the forum, where i can receive answer on my question
so bye

Reply all
Reply to author
Forward
0 new messages