postgresql: DB connection was unexpectedly closed while running local chainlink node - postgresql

I have been trying to run a local chainlink node in Windows 10, WSL1 - Ubuntu Distribution and postgresql 14.5. I am running the following command from WSL shell:
chainlink local n
But, I am getting the following error, displaying that db connection was unexpectedly closed:
DB connection was unexpectedly closed; checking out a new one pg/advisory_lock.go:178 advisoryLockID=1027321974924625846 err=sql: connection is already closed logger=1.10.0#9b1c622.RunNode.LockedDB.AdvisoryLock
2022-12-13T13:31:48.986+0530 [DEBUG] Taking advisory lock pg/advisory_lock.go:132 advisoryLockID=1027321974924625846 logger=1.10.0#9b1c622.RunNode.LockedDB.AdvisoryLock
2022-12-13T13:31:48.988+0530 [FATAL] Another node has taken the advisory lock, exiting immediately pg/advisory_lock.go:191
I have tried to set env variables in postgresql.conf file:
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
# (change requires restart)
#unix_socket_group = '' # (change requires restart)
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
# (change requires restart)
#bonjour = off # advertise server via Bonjour
tcp_keepalives_idle = 60 # TCP_KEEPIDLE, in seconds;
# 0 selects the system default
tcp_keepalives_interval = 60 # TCP_KEEPINTVL, in seconds;
# 0 selects the system default
tcp_keepalives_count = 10 # TCP_KEEPCNT;
# 0 selects the system default
tcp_user_timeout = 120 # TCP_USER_TIMEOUT, in milliseconds;
# 0 selects the system default
pg_hba.conf file
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
# (change requires restart)
#unix_socket_group = '' # (change requires restart)
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
# (change requires restart)
#bonjour = off # advertise server via Bonjour
Precise Terminal Output:
Listening and serving HTTP on port 6688 cmd/client.go:460 logger=1.10.0#9b1c622
2022-12-13T13:31:48.110+0530 [DEBUG] Fetching head headtracker/head_tracker.go:331 blockHeight=29636533 evmChainID=80001 logger=1.10.0#9b1c622.EVM.HeadTracker
2022-12-13T13:31:48.111+0530 [DEBUG] RPC call: evmclient.Client#CallContext client/node.go:426 args=["0x1c437b5",false] evmChainID=80001 logger=1.10.0#9b1c622.EVM.Node.RPC method=eth_getBlockByNumber mode=websocket node=(primary)primary-0-80001:wss://polished-divine-owl.matic-testnet.discover.quiknode.pro/API_KEY/ nodeName=primary-0-80001 nodeTier=primary requestID=a3f6a25f-9052-4382-bf2c-6b99a7ffe8b6
2022-12-13T13:31:48.321+0530 [DEBUG] evmclient.Client#CallContext RPC call success client/node.go:945 args=["0x1c437b5",false] callName=CallContext duration=0.2088953 evmChainID=80001 logger=1.10.0#9b1c622.EVM.Node.RPC method=eth_getBlockByNumber mode=websocket node=(primary)primary-0-80001:wss://polished-divine-owl.matic-testnet.discover.quiknode.pro/API_KEY/ nodeName=primary-0-80001 nodeTier=primary requestID=a3f6a25f-9052-4382-bf2c-6b99a7ffe8b6 rpcDomain=polished-divine-owl.matic-testnet.discover.quiknode.pro
2022-12-13T13:31:48.325+0530 [DEBUG] Fetching head headtracker/head_tracker.go:331 blockHeight=29636532 evmChainID=80001 logger=1.10.0#9b1c622.EVM.HeadTracker
2022-12-13T13:31:48.326+0530 [DEBUG] RPC call: evmclient.Client#CallContext client/node.go:426 args=["0x1c437b4",false] evmChainID=80001 logger=1.10.0#9b1c622.EVM.Node.RPC method=eth_getBlockByNumber mode=websocket node=(primary)primary-0-80001:wss://polished-divine-owl.matic-testnet.discover.quiknode.pro/API_KEY/ nodeName=primary-0-80001 nodeTier=primary requestID=REQUEST_ID
2022-12-13T13:31:48.332+0530 [WARN] DB connection was unexpectedly closed; checking out a new one pg/lease_lock.go:222 appID=33bf14d5-cdf9-4531-a7d3-55ab8e8bc9cd err=leaseLock#GetLease failed: failed to begin transaction: sql: connection is already closed errVerbose=sql: connection is already closed
failed to begin transaction
github.com/smartcontractkit/chainlink/core/services/pg.sqlxTransactionQ
/mnt/d/D/Langs/Blockchain/transaction-checker/chainlink/core/services/pg/transaction.go:91
github.com/smartcontractkit/chainlink/core/services/pg.(*leaseLock).getLease
/mnt/d/D/Langs/Blockchain/transaction-checker/chainlink/core/services/pg/lease_lock.go:258
github.com/smartcontractkit/chainlink/core/services/pg.(*leaseLock).loop
/mnt/d/D/Langs/Blockchain/transaction-checker/chainlink/core/services/pg/lease_lock.go:220
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1594
leaseLock#GetLease failed
github.com/smartcontractkit/chainlink/core/services/pg.(*leaseLock).getLease
/mnt/d/D/Langs/Blockchain/transaction-checker/chainlink/core/services/pg/lease_lock.go:291
github.com/smartcontractkit/chainlink/core/services/pg.(*leaseLock).loop
/mnt/d/D/Langs/Blockchain/transaction-checker/chainlink/core/services/pg/lease_lock.go:220
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1594 logger=1.10.0#9b1c622.RunNode.LockedDB.LeaseLock
2022-12-13T13:31:48.536+0530 [DEBUG] evmclient.Client#CallContext RPC call success client/node.go:945 args=["0x1c437b4",false] callName=CallContext duration=0.2095203 evmChainID=80001 logger=1.10.0#9b1c622.EVM.Node.RPC method=eth_getBlockByNumber mode=websocket node=(primary)primary-0-80001:wss://polished-divine-owl.matic-testnet.discover.quiknode.pro/API_KEY/ nodeName=primary-0-80001 nodeTier=primary requestID=REQUEST_ID rpcDomain=polished-divine-owl.matic-testnet.discover.quiknode.pro
2022-12-13T13:31:48.540+0530 [DEBUG] Fetching head headtracker/head_tracker.go:331 blockHeight=29636531 evmChainID=80001 logger=1.10.0#9b1c622.EVM.HeadTracker
2022-12-13T13:31:48.541+0530 [DEBUG] RPC call: evmclient.Client#CallContext client/node.go:426 args=["0x1c437b3",false] evmChainID=80001 logger=1.10.0#9b1c622.EVM.Node.RPC method=eth_getBlockByNumber mode=websocket node=(primary)primary-0-80001:wss://polished-divine-owl.matic-testnet.discover.quiknode.pro/API_KEY/ nodeName=primary-0-80001 nodeTier=primary requestID=154b805f-348b-415a-b728-d75743023962
2022-12-13T13:31:48.753+0530 [DEBUG] evmclient.Client#CallContext RPC call success client/node.go:945 args=["0x1c437b3",false] callName=CallContext duration=0.2098329 evmChainID=80001 logger=1.10.0#9b1c622.EVM.Node.RPC method=eth_getBlockByNumber mode=websocket node=(primary)primary-0-80001:wss://polished-divine-owl.matic-testnet.discover.quiknode.pro/API_KEY/ nodeName=primary-0-80001 nodeTier=primary requestID=154b805f-348b-415a-b728-d75743023962 rpcDomain=polished-divine-owl.matic-testnet.discover.quiknode.pro
2022-12-13T13:31:48.757+0530 [DEBUG] Fetching head headtracker/head_tracker.go:331 blockHeight=29636530 evmChainID=80001 logger=1.10.0#9b1c622.EVM.HeadTracker
2022-12-13T13:31:48.758+0530 [DEBUG] RPC call: evmclient.Client#CallContext client/node.go:426 args=["0x1c437b2",false] evmChainID=80001 logger=1.10.0#9b1c622.EVM.Node.RPC method=eth_getBlockByNumber mode=websocket node=(primary)primary-0-80001:wss://polished-divine-owl.matic-testnet.discover.quiknode.pro/API_KEY/ nodeName=primary-0-80001 nodeTier=primary requestID=1b3ff8e7-4781-4319-bb70-69a709725fc8
2022-12-13T13:31:48.968+0530 [DEBUG] evmclient.Client#CallContext RPC call success client/node.go:945 args=["0x1c437b2",false] callName=CallContext duration=0.209303 evmChainID=80001 logger=1.10.0#9b1c622.EVM.Node.RPC method=eth_getBlockByNumber mode=websocket node=(primary)primary-0-80001:wss://polished-divine-owl.matic-testnet.discover.quiknode.pro/API_KEY/ nodeName=primary-0-80001 nodeTier=primary requestID=1b3ff8e7-4781-4319-bb70-69a709725fc8 rpcDomain=polished-divine-owl.matic-testnet.discover.quiknode.pro
2022-12-13T13:31:48.974+0530 [DEBUG] Fetching head headtracker/head_tracker.go:331 blockHeight=29636529 evmChainID=80001 logger=1.10.0#9b1c622.EVM.HeadTracker
2022-12-13T13:31:48.975+0530 [DEBUG] RPC call: evmclient.Client#CallContext client/node.go:426 args=["0x1c437b1",false] evmChainID=80001 logger=1.10.0#9b1c622.EVM.Node.RPC method=eth_getBlockByNumber mode=websocket node=(primary)primary-0-80001:wss://polished-divine-owl.matic-testnet.discover.quiknode.pro/API_KEY/ nodeName=primary-0-80001 nodeTier=primary requestID=a364e758-2f45-47a7-afa7-87c70219b30e
2022-12-13T13:31:48.986+0530 [WARN] DB connection was unexpectedly closed; checking out a new one pg/advisory_lock.go:178 advisoryLockID=1027321974924625846 err=sql: connection is already closed logger=1.10.0#9b1c622.RunNode.LockedDB.AdvisoryLock
2022-12-13T13:31:48.986+0530 [DEBUG] Taking advisory lock pg/advisory_lock.go:132 advisoryLockID=1027321974924625846 logger=1.10.0#9b1c622.RunNode.LockedDB.AdvisoryLock
2022-12-13T13:31:48.988+0530 [FATAL] Another node has taken the advisory lock, exiting immediately pg/advisory_lock.go:191 advisoryLockID=1027321974924625846 logger=1.10.0#9b1c622.RunNode.LockedDB.AdvisoryLock stacktrace=github.com/smartcontractkit/chainlink/core/services/pg.(*advisoryLock).loop
Is the problem related to advisory locks? Because, localhost:6688 responds for few seconds, then abruptly stops due to the error db connection was unexpectedly closed. Have been into this for around 2 days. Any help is appreciated. Thank you!

Related

dovecot mail_crypt failed to initialize user,mail_crypt_global_private_key mail_crypt_global_private_key_password unset,no password to decrypt the key

I have been using postfix+dovecot successfully for a while now until I tried mail crypt plugin lately. I tried what is describe here https://doc.dovecot.org/configuration_manual/mail_crypt_plugin/ and I went for global-keys as described here: https://doc.dovecot.org/configuration_manual/mail_crypt_plugin/#global-keys
"A good solution for environments where no user folder sharing is needed is to generate per-user EC key pair and encrypt that with something derived from user’s password."
I am setting mail_crypt_global_private_key, mail_crypt_global_public_key, mail_crypt_save_version from user_query and userdb_mail_crypt_global_private_key_password from password_query. mail_crypt seems to work fine in imap (I saved a message as draft and it is stored encrypted on the disk), but lmtp complains about "mail_crypt_global_private_key_password unset, no password to decrypt the key" As you can see below in logs that it was able to set all other mail_crypt_ configurations successfully from user_query. However, the password is provided via password_query and I assume lmtp does not read password_query. How else can I provide a password in lmtp (Why do lmtp needs a password, can it not use public key to encrypt)? Is my approach correct to begin with?
-- Dovecot Configurations --
# using doveconf -n
# 2.3.19.1 (9b53102964): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.5.19 (4eae2f79)
# OS: Linux 5.15.0-57-generic x86_64 Ubuntu 20.04.5 LTS
# Hostname: mailserver-dovecot-7c9ff7b94b-8ldrr
auth_mechanisms = plain login
auth_verbose = yes
auth_verbose_passwords = yes
debug_log_path = /dev/stdout
haproxy_trusted_networks = 192.168.0.0/16 10.10.10.0/24 10.10.30.0/24 172.17.0.1/16
hostname = imap.mailserver.k8s.local pop.mailserver.k8s.local
info_log_path = /dev/stdout
listen = *
log_path = /dev/stdout
mail_debug = yes
mail_gid = 1000
mail_home = /var/vmail/mailboxes/%d/%n
mail_location = maildir:~/:LAYOUT=fs
mail_plugins = quota mail_crypt
mail_privileged_group = mail
mail_uid = 1000
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext imapsieve vnd.dovecot.imapsieve
namespace inbox {
inbox = yes
location =
mailbox Drafts {
auto = subscribe
special_use = \Drafts
}
mailbox Sent {
auto = subscribe
special_use = \Sent
}
mailbox "Sent Messages" {
special_use = \Sent
}
mailbox Spam {
auto = subscribe
autoexpunge = 30 days
special_use = \Junk
}
mailbox Trash {
auto = subscribe
autoexpunge = 30 days
special_use = \Trash
}
prefix =
}
passdb {
args = /etc/dovecot/dovecot-sql.conf.ext
driver = sql
}
plugin {
imapsieve_mailbox1_before = file:/var/vmail/sieve/global/learn-spam.sieve
imapsieve_mailbox1_causes = COPY APPEND FLAG
imapsieve_mailbox1_name = Spam
imapsieve_mailbox2_before = file:/var/vmail/sieve/global/learn-ham.sieve
imapsieve_mailbox2_causes = COPY APPEND FLAG
imapsieve_mailbox2_from = Spam
imapsieve_mailbox2_name = *
mail_crypt_save_version = 0
quota = maildir:User quota
quota_exceeded_message = User %u has exhausted allowed storage space.
quota_rule = Junk:ignore
quota_rule2 = Trash:storage=+100M
quota_warning = storage=90%% quota-warning 90 %u %d
quota_warning2 = storage=80%% quota-warning 80 %u %d
sieve = file:~/sieve;active=~/.dovecot.sieve
sieve_before = /var/vmail/sieve/global/spam-global.sieve
sieve_global = /var/vmail/sieve/global/
sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.debug
sieve_pipe_bin_dir = /var/vmail/sieve/global
sieve_plugins = sieve_imapsieve sieve_extprograms
}
protocols = " imap lmtp sieve pop3"
service auth {
inet_listener {
port = 25252
}
}
service imap-login {
inet_listener imap {
haproxy = yes
}
inet_listener imaps {
haproxy = yes
ssl = yes
}
}
service lmtp {
executable = lmtp -L
inet_listener lmtp {
address = 0.0.0.0
port = 24
}
}
service managesieve-login {
inet_listener sieve {
port = 4190
}
}
service pop3-login {
inet_listener pop3 {
haproxy = yes
}
inet_listener pop3s {
haproxy = yes
}
}
ssl = required
ssl_cert = </etc/dovecot/certs/tls.crt
ssl_client_ca_dir = /etc/ssl/certs
ssl_key = # hidden, use -P to show it
ssl_prefer_server_ciphers = yes
userdb {
args = /etc/dovecot/dovecot-sql.conf.ext
driver = sql
}
protocol lmtp {
info_log_path = /dev/stdout
log_path = /dev/stdout
mail_plugins = quota mail_crypt sieve
postmaster_address = <hidden>
}
protocol imap {
mail_plugins = quota mail_crypt quota imap_quota imap_sieve
}
-- Dovecot Configurations Ends --
-- Password Query --
password_query = \
SELECT username, domain, password, \
'%{sha256:password}' AS userdb_mail_crypt_global_private_key_password \
FROM mailbox \
WHERE username='%u';
-- Password Query Ends--
-- User Query --
user_query = SELECT CONCAT('*:bytes=', 1024) as quota_rule, \
private_key AS mail_crypt_global_private_key, \
public_key AS mail_crypt_global_public_key, \
mail_crypt_save_version AS mail_crypt_save_version \
FROM mailbox \
WHERE username='%u';
-- User Query Ends --
-- Debug Logs --
--- Load Inbox ---
imap-login: Info: Login: user=<someone#example.com>, method=PLAIN, rip=192.168.49.1, lip=192.168.49.2, mpid=241, TLS, session=<oaoI9sLxVKXAqDEB>
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Loading modules from directory: /usr/lib/dovecot/modules
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Module loaded: /usr/lib/dovecot/modules/lib10_mail_crypt_plugin.so
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Module loaded: /usr/lib/dovecot/modules/lib10_quota_plugin.so
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Module loaded: /usr/lib/dovecot/modules/lib11_imap_quota_plugin.so
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Module loaded: /usr/lib/dovecot/modules/lib95_imap_sieve_plugin.so
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Added userdb setting: plugin/mail_crypt_global_private_key=LS0tLS1CRUd.....LS0tLS0K
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Added userdb setting: plugin/mail_crypt_global_private_key_password=<hidden>
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Added userdb setting: plugin/mail_crypt_global_public_key=LS0tLS1CRUd.....LS0tCg==
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Added userdb setting: plugin/mail_crypt_save_version=2
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Added userdb setting: plugin/quota_rule=*:bytes=1024000000
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Effective uid=1000, gid=1000, home=/var/vmail/mailboxes/example.com/someone
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: mail_crypt_plugin: mail_crypt_curve setting missing - generating EC keys disabled
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Quota root: name=User quota backend=maildir args=
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Quota rule: root=User quota mailbox=* bytes=1024000000 messages=0
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Quota rule: root=User quota mailbox=Trash bytes=+104857600 messages=0
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Quota warning: bytes=921600000 (90%) messages=0 reverse=no command=quota-warning 90 someone#example.com example.com
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Quota warning: bytes=819200000 (80%) messages=0 reverse=no command=quota-warning 80 someone#example.com example.com
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Quota grace: root=User quota bytes=102400000 (10%)
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: open(/proc/self/io) failed: Permission denied
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Namespace inbox: type=private, prefix=, sep=, inbox=yes, hidden=no, list=yes, subscriptions=yes location=maildir:~/:LAYOUT=fs
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: fs: root=/var/vmail/mailboxes/example.com/someone, index=, indexpvt=, control=, inbox=/var/vmail/mailboxes/example.com/someone, alt=
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: quota: quota_over_flag check: quota_over_script unset - skipping
imap(someone#example.com)<241><oaoI9sLxVKXAqDEB>: Debug: Mailbox INBOX: Mailbox opened
--- Load Inbox Ends ---
--- Lmtp ---
lmtp(248): Info: Connect from 172.17.0.1
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: auth-master: userdb lookup(someone#example.com): Started userdb lookup
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: auth-master: conn unix:/var/run/dovecot/auth-userdb: Connecting
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: auth-master: conn unix:/var/run/dovecot/auth-userdb (pid=143,uid=0): Client connected (fd=18)
imap(someone#example.com)<247><WlggG8PxEOvAqDEB>: Debug: Mailbox Sent: Purging (new file_seq=1673195172): creating cache
imap(someone#example.com)<247><WlggG8PxEOvAqDEB>: Debug: Mailbox Sent: Purging finished, file_seq changed 0 -> 1673195172, size=0 -> 388, max_uid=0
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: auth-master: userdb lookup(someone#example.com): auth USER input: someone#example.com quota_rule=*:bytes=1024000000 mail_crypt_global_private_key=LS0tLS1CRUd.....LS0tLS0K mail_crypt_global_public_key=LS0tLS1CRUd.....LS0tCg== mail_crypt_save_version=2
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: auth-master: userdb lookup(someone#example.com): Finished userdb lookup (username=someone#example.com quota_rule=*:bytes=1024000000 mail_crypt_global_private_key=LS0tLS1CRUd.....LS0tLS0K mail_crypt_global_public_key=LS0tLS1CRUd.....LS0tCg== mail_crypt_save_version=2)
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: lmtp-server: conn 172.17.0.1:6376 [1]: rcpt someone#example.com: Added userdb setting: plugin/mail_crypt_global_private_key=LS0tLS1CRUd.....LS0tLS0K
imap(someone#example.com)<247><WlggG8PxEOvAqDEB>: Debug: duplicate db: Initialize
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: lmtp-server: conn 172.17.0.1:6376 [1]: rcpt someone#example.com: Added userdb setting: plugin/mail_crypt_global_public_key=LS0tLS1CRUd.....LS0tCg==
imap(someone#example.com)<247><WlggG8PxEOvAqDEB>: Debug: sieve: Pigeonhole version 0.5.19 (4eae2f79) initializing
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: lmtp-server: conn 172.17.0.1:6376 [1]: rcpt someone#example.com: Added userdb setting: plugin/mail_crypt_save_version=2
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: lmtp-server: conn 172.17.0.1:6376 [1]: rcpt someone#example.com: Added userdb setting: plugin/quota_rule=*:bytes=1024000000
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: lmtp-server: conn 172.17.0.1:6376 [1]: rcpt someone#example.com: Effective uid=1000, gid=1000, home=/var/vmail/mailboxes/example.com/someone
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: lmtp-server: conn 172.17.0.1:6376 [1]: rcpt someone#example.com: mail_crypt_plugin: mail_crypt_curve setting missing - generating EC keys disabled
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: lmtp-server: conn 172.17.0.1:6376 [1]: rcpt someone#example.com: Quota root: name=User quota backend=maildir args=
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: lmtp-server: conn 172.17.0.1:6376 [1]: rcpt someone#example.com: Quota rule: root=User quota mailbox=* bytes=1024000000 messages=0
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: lmtp-server: conn 172.17.0.1:6376 [1]: rcpt someone#example.com: Quota rule: root=User quota mailbox=Trash bytes=+104857600 messages=0
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: lmtp-server: conn 172.17.0.1:6376 [1]: rcpt someone#example.com: Quota warning: bytes=921600000 (90%) messages=0 reverse=no command=quota-warning 90 someone#example.com example.com
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: lmtp-server: conn 172.17.0.1:6376 [1]: rcpt someone#example.com: Quota warning: bytes=819200000 (80%) messages=0 reverse=no command=quota-warning 80 someone#example.com example.com
lmtp(someone#example.com)<248><e2dcD6TuumP4AAAALzF/Qw>: Debug: lmtp-server: conn 172.17.0.1:6376 [1]: rcpt someone#example.com: Quota grace: root=User quota bytes=102400000 (10%)
lmtp(248): Error: lmtp-server: conn 172.17.0.1:6376 [1]: rcpt someone#example.com: Failed to initialize user: mail_crypt_plugin: mail_crypt_global_private_key: mail_crypt_global_private_key_password unset, no password to decrypt the key
lmtp(248): Info: Disconnect from 172.17.0.1: Logged out (state=READY)
--- Lmtp Ends ---
-- Debug Logs Ends --

TLS/SSL in pgbouncer - FATAL TLS setup failed: failed to load CA

I'm trying to set up pgbouncer to require a TLS/SSL connection from the applications connecting to it, but it throws an error "FATAL TLS setup failed: failed to load CA"
This is my pgbouncer.ini:
[databases]
* = host=${postgres_host} port=5432
[pgbouncer]
# Do not change these settings:
listen_addr = 0.0.0.0
auth_file = /etc/pgbouncer/userlist.txt
auth_type = trust
client_tls_sslmode = require
client_tls_key_file = /etc/pgbouncer/server.key
client_tls_cert_file = /etc/pgbouncer/server.crt
server_tls_sslmode = verify-ca
server_tls_ca_file = /etc/root.crt.pem
# These are defaults and can be configured
# please leave them as defaults if you are
# uncertain.
listen_port = 5432
unix_socket_dir =
user = postgres
pool_mode = transaction
max_client_conn = 100
ignore_startup_parameters = extra_float_digits
admin_users = postgres
# Please add any additional settings below this line
but running it it throws this error, which doesn't seem correct since a CA root file is not needed.
FATAL TLS setup failed: failed to load CA: No such file or directory
p.s. It threw the error also before I had server_tlsmode = verify-ca

SSH connect to server in SwiftUI

I am trying to write a little SwiftUI app that connects to my server so I can display files and visually use SFTP (kind of like FileZilla). I have a function called SSH that executes on a button press, here it is:
func ssh(user: String, domain: String, password: String) {
let arg = "ssh " + user + "#" + domain
let task = Process()
task.launchPath = "/usr/bin/ssh"
task.arguments = [arg]
task.launch()
task.waitUntilExit()
}
When I call the function, I get this nasty error message in the Xcode console:
2020-11-25 11:05:35.122998-0800 SFTP App[25287:1434441] Metal API Validation Enabled
2020-11-25 11:05:49.056839-0800 ssh[25291:1434628] [] nw_resolver_can_use_dns_xpc_block_invoke Sandbox does not allow access to com.apple.dnssd.service
2020-11-25 11:05:49.057250-0800 ssh[25291:1434628] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:4 Err:-1 Errno:1 Operation not permitted
2020-11-25 11:05:49.057351-0800 ssh[25291:1434628] [connection] nw_resolver_create_dns_service_locked [C1] DNSServiceCreateDelegateConnection failed: ServiceNotRunning(-65563)
ssh: Could not resolve hostname connect.markregg.com: -65563
I am able to connect to my server using the following terminal command and then entering my password:
ssh mark#connect.markregg.com

Ejabberd - ejabberd_auth_external:failure:103 External authentication program failed when calling 'check_password'

I already have a schema of users with authentication-key and wanted to do authentication via that. I tried implementing authentication via sql but due to different structure of my schema I was getting error and so I implemented external-authentication method. The technologies and OS used in my application are :
Node.JS
Ejabberd as XMPP server
MySQL Database
React-Native (Front-End)
OS - Ubuntu 18.04
I implemented the external authentication configuration as mentioned in https://docs.ejabberd.im/admin/configuration/#external-script and took php script https://www.ejabberd.im/files/efiles/check_mysql.php.txt as an example. But I am getting the below mentioned error in error.log. In ejabberd.yml I have done following configuration.
...
host_config:
"example.org.co":
auth_method: [external]
extauth_program: "/usr/local/etc/ejabberd/JabberAuth.class.php"
auth_use_cache: false
...
Also, is there any external auth javascript script?
Here is the error.log and ejabberd.log as mentioned below
error.log
2019-03-19 07:19:16.814 [error]
<0.524.0>#ejabberd_auth_external:failure:103 External authentication
program failed when calling 'check_password' for admin#example.org.co:
disconnected
ejabberd.log
2019-03-19 07:19:16.811 [debug] <0.524.0>#ejabberd_http:init:151 S:
[{[<<"api">>],mod_http_api},{[<<"admin">>],ejabberd_web_admin}]
2019-03-19 07:19:16.811 [debug]
<0.524.0>#ejabberd_http:process_header:307 (#Port<0.13811>) http
query: 'POST' <<"/api/register">>
2019-03-19 07:19:16.811 [debug]
<0.524.0>#ejabberd_http:process:394 [<<"api">>,<<"register">>] matches
[<<"api">>]
2019-03-19 07:19:16.811 [info]
<0.364.0>#ejabberd_listener:accept:238 (<0.524.0>) Accepted connection
::ffff:ip -> ::ffff:ip
2019-03-19 07:19:16.814 [info]
<0.524.0>#mod_http_api:log:548 API call register
[{<<"user">>,<<"test">>},{<<"host">>,<<"example.org.co">>},{<<"password">>,<<"test">>}]
from ::ffff:ip
2019-03-19 07:19:16.814 [error]
<0.524.0>#ejabberd_auth_external:failure:103 External authentication
program failed when calling 'check_password' for admin#example.org.co:
disconnected
2019-03-19 07:19:16.814 [debug]
<0.524.0>#mod_http_api:extract_auth:171 Invalid auth data:
{error,invalid_auth}
Any help regarding this topic will be appreciated.
1) Your config about the auth_method looks good.
2) Here is a python script I've used and upgraded to make an external authentication for ejabberd.
#!/usr/bin/python
import sys
from struct import *
import os
def openAuth(args):
(user, server, password) = args
# Implement your interactions with your service / database
# Return True or False
return True
def openIsuser(args):
(user, server) = args
# Implement your interactions with your service / database
# Return True or False
return True
def loop():
switcher = {
"auth": openAuth,
"isuser": openIsuser,
"setpass": lambda(none): True,
"tryregister": lambda(none): False,
"removeuser": lambda(none): False,
"removeuser3": lambda(none): False,
}
data = from_ejabberd()
to_ejabberd(switcher.get(data[0], lambda(none): False)(data[1:]))
loop()
def from_ejabberd():
input_length = sys.stdin.read(2)
(size,) = unpack('>h', input_length)
return sys.stdin.read(size).split(':')
def to_ejabberd(result):
if result:
sys.stdout.write('\x00\x02\x00\x01')
else:
sys.stdout.write('\x00\x02\x00\x00')
sys.stdout.flush()
if __name__ == "__main__":
try:
loop()
except error:
pass
I didn't created the communication with Ejabberd from_ejabberd() and to_ejabberd(), and unfortunately can't find back the sources.

How do I resolve a MongoDB timeout error when connecting via the Scala Play! framework?

I am connecting to MongoDB while using the Scala Play! framework. I end up getting this timeout error:
! #6j672dke5 - Internal server error, for (GET) [/accounts] ->
play.api.Application$$anon$1: Execution exception[[MongoTimeoutException: Timed out while waiting to connect after 10000 ms]]
at play.api.Application$class.handleError(Application.scala:293) ~[play_2.10-2.2.1.jar:2.2.1]
at play.api.DefaultApplication.handleError(Application.scala:399) [play_2.10-2.2.1.jar:2.2.1]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$12$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:165) [play_2.10-2.2.1.jar:2.2.1]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$12$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:162) [play_2.10-2.2.1.jar:2.2.1]
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:33) [scala-library-2.10.4.jar:na]
at scala.util.Failure$$anonfun$recover$1.apply(Try.scala:185) [scala-library-2.10.4.jar:na]
Caused by: com.mongodb.MongoTimeoutException: Timed out while waiting to connect after 10000 ms
at com.mongodb.BaseCluster.getDescription(BaseCluster.java:131) ~[mongo-java-driver-2.12.3.jar:na]
at com.mongodb.DBTCPConnector.getClusterDescription(DBTCPConnector.java:396) ~[mongo-java-driver-2.12.3.jar:na]
at com.mongodb.DBTCPConnector.getType(DBTCPConnector.java:569) ~[mongo-java-driver-2.12.3.jar:na]
at com.mongodb.DBTCPConnector.isMongosConnection(DBTCPConnector.java:370) ~[mongo-java-driver-2.12.3.jar:na]
at com.mongodb.Mongo.isMongosConnection(Mongo.java:645) ~[mongo-java-driver-2.12.3.jar:na]
at com.mongodb.DBCursor._check(DBCursor.java:454) ~[mongo-java-driver-2.12.3.jar:na]
Here is my Scala code for connecting to the database:
//models.scala
package models.mongodb
//imports
package object mongoContext {
//context stuff
val client = MongoClient(current.configuration.getString("mongo.host").toString())
val database = client(current.configuration.getString("mongo.database").toString())
}
Here is the actual model that is making the connection:
//google.scala
package models.mongodb
//imports
case class Account(
id: ObjectId = new ObjectId,
name: String
)
object AccountDAO extends SalatDAO[Account, ObjectId](
collection = mongoContext.database("accounts")
)
object Account {
def all(): List[Account] = AccountDAO.find(MongoDBObject.empty).toList
}
Here's the Play! framework MongoDB conf information:
# application.conf
# mongodb connection details
mongo.host="localhost"
mongo.port=27017
mongo.database="advanced"
Mongodb is running on my local machine. I can connect to it by typing mongo at the terminal window. Here's the relevant part of the conf file:
# mongod.conf
# Where to store the data.
# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
dbpath=/var/lib/mongodb
#where to log
logpath=/var/log/mongodb/mongod.log
logappend=true
#port = 27017
# Listen to local interface only. Comment out to listen on all interfaces.
#bind_ip = 127.0.0.1
So what's causing this timeout error and how do I fix it? Thanks!
I figured out that I needed to change:
val client = MongoClient(current.configuration.getString("mongo.host").toString())
val database = client(current.configuration.getString("mongo.database").toString())
to:
val client = MongoClient(conf.getString("mongo.host"))
val database = client(conf.getString("mongo.database"))