cameri / nostream

A Nostr Relay written in TypeScript
MIT License
729 stars 188 forks source link

[BUG] Where is the data in PostgreSQL database? #222

Open yaohaizhou opened 1 year ago

yaohaizhou commented 1 year ago

Describe the bug I have deployed a Nostream relay on my server. I use Damus to post a node and it works fine. However, I cannot find any event in PostgreSQL database. How can I read the database?

To Reproduce Steps to reproduce the behavior:

  1. docker container ls to find the container id for PostgreSQL
  2. docker exec -it id bash
  3. (inside the docker) psql -U nostr_ts_relay -W
  4. enter the passward nostr_ts_relay
  5. \d List of relations Schema | Name | Type | Owner
    --------+--------------------------------+----------+---------------- public | events | table | nostr_ts_relay public | invoices | table | nostr_ts_relay public | knex_migrations | table | nostr_ts_relay public | knex_migrations_id_seq | sequence | nostr_ts_relay public | knex_migrations_lock | table | nostr_ts_relay public | knex_migrations_lock_index_seq | sequence | nostr_ts_relay public | users | table | nostr_ts_relay (7 rows)
  6. select * from events and nothing returns

PS: Also, I try to connect the database outside the docker (in Ubuntu physical machine shell), but I cannot log in. psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "nostr_ts_relay"

System (please complete the following information):

neilck commented 1 year ago

Nostream uses redis as a caching layer. New events do not immediately show up in nostr_ts_relay.Schemas.public.Tables.events, but will eventually. I don't know how long the delay is.

cameri commented 1 year ago

There's no delay. Events should show automatically. Check the logs on your docker containers to see if there's an issue.

dterhorst commented 1 year ago

Did you forget the ; after select * from events?

select * from events;

cameri commented 1 year ago

@zyhhhy the PostgreSQL database port is not exposed by default. You have to edit the docker-compose.yml file and edit the nostream-db section to add the ports. It's not recommended that you expose the database this way, if you do make sure the external port is not 5432 or that you have a firewall in place blocking access to this port from the outside world.

Nostream responds with an OK message with true if the event is accepted or false and a reason if the event is rejected. Use a Nostr client that lets you see this information.