romanz / electrs

An efficient re-implementation of Electrum Server in Rust
MIT License
1.1k stars 407 forks source link

Getting receiving on an empty and disconnected channel running in docker #1055

Open punithbm opened 5 months ago

punithbm commented 5 months ago

Getting following error in the electrs, can you please help me what might be the wrong

electrs error log,

Starting electrs 0.10.5 on x86_64 linux with Config { network: Signet, db_path: "/data/signet", db_log_dir: None, daemon_dir: "/bitcoin/signet", daemon_auth: CookieFile("/bitcoin/.cookie"), daemon_rpc_addr: 68.183.80.225:38332, daemon_p2p_addr: 68.183.80.225:38333, electrum_rpc_addr: 0.0.0.0:50001, monitoring_addr: 0.0.0.0:4224, wait_duration: 10s, jsonrpc_timeout: 15s, index_batch_size: 10, index_lookup_limit: None, reindex_last_blocks: 0, auto_reindex: true, ignore_mempool: false, sync_once: false, skip_block_download_wait: false, disable_electrum_rpc: false, server_banner: "Welcome to electrs 0.10.5 (Electrum Rust Server)!", signet_magic: 0a03cf40, args: [] }
[2024-06-17T17:08:04.305Z INFO  electrs::metrics::metrics_impl] serving Prometheus metrics on 0.0.0.0:4224
[2024-06-17T17:08:04.305Z INFO  electrs::server] serving Electrum RPC on 0.0.0.0:50001
[2024-06-17T17:08:04.324Z INFO  electrs::db] "/data/signet": 20 SST files, 0.00002062 GB, 0.00000002 Grows
[2024-06-17T17:08:04.325Z DEBUG electrs::db] DB Some(Config { compacted: false, format: 0 })
[2024-06-17T17:08:04.329Z TRACE electrs::p2p] send: Version(VersionMessage { version: 70001, services: ServiceFlags(0), timestamp: 1718644084, receiver: Address {services: ServiceFlags(NONE), address: 0.0.0.0, port: 0}, sender: Address {services: ServiceFlags(NONE), address: 0.0.0.0, port: 0}, nonce: 11582491815844596145, user_agent: "/electrs:0.10.5/", start_height: 0, relay: false })
[2024-06-17T17:08:04.330Z DEBUG electrs::p2p] closing p2p_recv thread: connection closed
[2024-06-17T17:08:04.330Z DEBUG electrs::p2p] closing p2p_loop thread: peer has disconnected
[2024-06-17T17:08:04.330Z DEBUG electrs::p2p] closing p2p_send thread: no more messages to send
[2024-06-17T17:08:04.330Z INFO  electrs::db] closing DB at /data/signet
Error: electrs failed

Caused by:
    receiving on an empty and disconnected channel

bitcoin.conf file

signet=1
rpccookiefile=/root/.bitcoin/.cookie
rpcauth=bitcoin:xxxxxxxxxxxxxxxxxxxxxxxxxx
txindex=1
blockfilterindex=1
peerblockfilters=1
coinstatsindex=1
dnsseed=0
persistmempool=1
uacomment=CustomSignet
[signet]
daemon=1
listen=1
server=1
debug=net
discover=1
signetchallenge=512102de2d9ca0a9a584ee89ef099d3c4aff9710e257251c4a030a6fa878b7eecef94751ae
signetblocktime=10
zmqpubrawblock=tcp://0.0.0.0:28332
zmqpubrawtx=tcp://0.0.0.0:28333
zmqpubhashblock=tcp://0.0.0.0:28334
rpcbind=0.0.0.0:38332
rpcallowip=0.0.0.0/0
whitelist=0.0.0.0/0
fallbackfee=0.0002
bind=0.0.0.0
port=38333
Kixunil commented 5 months ago

Looks like your bitcoind got shutdown, can you check its logs?

punithbm commented 5 months ago

No, Its running - http://68.183.80.225:38332

Screenshot 2024-06-17 at 11 49 09 PM

wondering what could've gone wrong

Kixunil commented 5 months ago

Please check the logs from around 17:08:04, bitcoind should say some reason why it disconnects.

punithbm commented 5 months ago

tried again now, same error. How can check the required logs for this ?

Screenshot 2024-06-17 at 11 57 17 PM
Kixunil commented 5 months ago

I guess you need to increase verbosity of bitcoind somehow.

Kixunil commented 5 months ago

Is it possible that you're missing signet_magic configuration option?

punithbm commented 5 months ago

but it takes default value for signet_magic: 0a03cf40 if not set right ?

Kixunil commented 5 months ago

Yes but you've set signet challenge which might affect it but I don't really have much knowledge here. Just guessing.

punithbm commented 5 months ago

Ok, do you think may be due to this error ? Error: Cannot obtain a lock on data directory /root/.bitcoin/signet. Bitcoin Core is probably already running.

i can see this error on startup.. do you know how to clear that ?

antonilol commented 5 months ago

bitcoin core probably disconnects electrs because the network magic is wrong, see https://en.bitcoin.it/wiki/Signet the magic in the electrs config is the default signet magic, but you use a custom signet challenge, so you need to calculate your own network magic and put it in the config for electrs

"The protocol message header bytes are dynamically generated based on the block challenge" ('message header bytes' is the exact same thing as 'network magic')

punithbm commented 5 months ago

Thanks a lot for your response, do you know how to calculate and set network magic in bitcoin conf ?

Kixunil commented 5 months ago

You need to set it in electrs, not bitcoin.conf. I don't know how to calculate it.

punithbm commented 5 months ago

its available in the signet debug logs as well, Got it thanks for the help

antonilol commented 5 months ago

The same Bitcoin wiki page also mentions how to calculate the megic bytes from the signet challenge, the first 4 bytes of sha256d(challenge_len || challenge) (length is encoded as a typical bitcoin consensus varint)

https://en.bitcoin.it/wiki/Signet#Genesis_Block_and_Message_Header

riegersan commented 2 months ago

I have the exact same problem on mainnet for some days

`Electrum attempting reconnect... syncPercent error: Error: close connect at /app/node_modules/@lily-technologies/electrum-client/lib/client.js:230:37 at Array.forEach () at ElectrumClient.onClose (/app/node_modules/@lily-technologies/electrum-client/lib/client.js:229:44) at ElectrumClient.onClose (/app/node_modules/@lily-technologies/electrum-client/index.js:69:9) at Socket. (/app/node_modules/@lily-technologies/electrum-client/lib/client.js:60:9) Starting electrs 0.10.2 on x86_64 linux with Config { network: Bitcoin, db_path: "/data/db/bitcoin", db_log_dir: None, daemon_dir: "/data/.bitcoin", daemon_auth: CookieFile("/data/.bitcoin/.cookie"), daemon_rpc_addr: 10.21.21.8:8332, daemon_p2p_addr: 10.21.21.8:8333, electrum_rpc_addr: 0.0.0.0:50001, monitoring_addr: 127.0.0.1:4224, wait_duration: 10s, jsonrpc_timeout: 15s, index_batch_size: 10, index_lookup_limit: None, reindex_last_blocks: 0, auto_reindex: true, ignore_mempool: false, sync_once: false, skip_block_download_wait: false, disable_electrum_rpc: false, server_banner: "Umbrel Electrs (0.10.2)", signet_magic: f9beb4d9, args: [] } [2024-08-26T06:35:54.339Z INFO electrs::metrics::metrics_impl] serving Prometheus metrics on 127.0.0.1:4224 [2024-08-26T06:35:54.339Z INFO electrs::server] serving Electrum RPC on 0.0.0.0:50001 [2024-08-26T06:35:54.368Z INFO electrs::db] "/data/db/bitcoin": 205 SST files, 49.271868142 GB, 6.15817247 Grows [2024-08-26T06:35:55.101Z INFO electrs::chain] loading 857616 headers, tip=000000000000000000000eebdc7d1097dc0caee5d639ba8a7711cc274f6cc923 [2024-08-26T06:35:55.631Z INFO electrs::chain] chain updated: tip=000000000000000000000eebdc7d1097dc0caee5d639ba8a7711cc274f6cc923, height=857616 [2024-08-26T06:35:55.638Z INFO electrs::db] closing DB at /data/db/bitcoin at Socket.emit (node:events:527:28) [2024-08-26T06:35:55.638Z WARN electrs::p2p] failed to shutdown p2p connection: Transport endpoint is not connected (os error 107) at TCP. (node:net:709:12) Error: electrs failed

Caused by: receiving on an empty and disconnected channel Starting electrs 0.10.2 on x86_64 linux with Config { network: Bitcoin, db_path: "/data/db/bitcoin", db_log_dir: None, daemon_dir: "/data/.bitcoin", daemon_auth: CookieFile("/data/.bitcoin/.cookie"), daemon_rpc_addr: 10.21.21.8:8332, daemon_p2p_addr: 10.21.21.8:8333, electrum_rpc_addr: 0.0.0.0:50001, monitoring_addr: 127.0.0.1:4224, wait_duration: 10s, jsonrpc_timeout: 15s, index_batch_size: 10, index_lookup_limit: None, reindex_last_blocks: 0, auto_reindex: true, ignore_mempool: false, sync_once: false, skip_block_download_wait: false, disable_electrum_rpc: false, server_banner: "Umbrel Electrs (0.10.2)", signet_magic: f9beb4d9, args: [] } [2024-08-26T06:36:55.881Z INFO electrs::metrics::metrics_impl] serving Prometheus metrics on 127.0.0.1:4224 [2024-08-26T06:36:55.881Z INFO electrs::server] serving Electrum RPC on 0.0.0.0:50001 [2024-08-26T06:36:55.904Z INFO electrs::db] "/data/db/bitcoin": 206 SST files, 49.27186916 GB, 6.158172471 Grows [2024-08-26T06:36:56.597Z INFO electrs::chain] loading 857616 headers, tip=000000000000000000000eebdc7d1097dc0caee5d639ba8a7711cc274f6cc923 [2024-08-26T06:36:57.085Z INFO electrs::chain] chain updated: tip=000000000000000000000eebdc7d1097dc0caee5d639ba8a7711cc274f6cc923, height=857616 [2024-08-26T06:36:57.091Z WARN electrs::p2p] failed to shutdown p2p connection: Transport endpoint is not connected (os error 107) [2024-08-26T06:36:57.091Z INFO electrs::db] closing DB at /data/db/bitcoin Error: electrs failed

Caused by: receiving on an empty and disconnected channel ::ffff:10.21.0.17 - - [Mon, 26 Aug 2024 06:35:26 GMT] "GET /v1/electrs/syncPercent HTTP/1.1" 500 2 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Safari/605.1.15" `

joel-regen commented 1 week ago

I'm having the same issue on Umbrel OS 1.2.2 running on raspberry pi 5: umbrel@umbrel:~/umbrel$ sudo docker logs 2a9f90fd3169 | tail -50 Starting electrs 0.10.6 on aarch64 linux with Config { network: Bitcoin, db_path: "/data/db/bitcoin", db_log_dir: None, daemon_dir: "/data/.bitcoin", daemon_auth: CookieFile("/data/.bitcoin/.cookie"), daemon_rpc_addr: 10.21.21.8:8332, daemon_p2p_addr: 10.21.21.8:8333, electrum_rpc_addr: 0.0.0.0:50001, monitoring_addr: 127.0.0.1:4224, wait_duration: 10s, jsonrpc_timeout: 15s, index_batch_size: 10, index_lookup_limit: None, reindex_last_blocks: 0, auto_reindex: true, ignore_mempool: false, sync_once: false, skip_block_download_wait: false, disable_electrum_rpc: false, server_banner: "Umbrel Electrs (0.10.6)", signet_magic: f9beb4d9 } [2024-11-16T11:34:01.039Z INFO electrs::metrics::metrics_impl] serving Prometheus metrics on 127.0.0.1:4224 [2024-11-16T11:34:01.039Z INFO electrs::server] serving Electrum RPC on 0.0.0.0:50001 [2024-11-16T11:34:01.103Z INFO electrs::db] "/data/db/bitcoin": 99 SST files, 0.00010076 GB, 0.000000021 Grows [2024-11-16T11:34:01.119Z WARN electrs::thread] p2p_recv thread failed: failed to recv a message from peer: IO error [2024-11-16T11:34:01.120Z INFO electrs::db] closing DB at /data/db/bitcoin [2024-11-16T11:34:01.120Z WARN electrs::p2p] failed to shutdown p2p connection: Transport endpoint is not connected (os error 107) Error: electrs failed

Caused by: receiving on an empty and disconnected channel Starting electrs 0.10.6 on aarch64 linux with Config { network: Bitcoin, db_path: "/data/db/bitcoin", db_log_dir: None, daemon_dir: "/data/.bitcoin", daemon_auth: CookieFile("/data/.bitcoin/.cookie"), daemon_rpc_addr: 10.21.21.8:8332, daemon_p2p_addr: 10.21.21.8:8333, electrum_rpc_addr: 0.0.0.0:50001, monitoring_addr: 127.0.0.1:4224, wait_duration: 10s, jsonrpc_timeout: 15s, index_batch_size: 10, index_lookup_limit: None, reindex_last_blocks: 0, auto_reindex: true, ignore_mempool: false, sync_once: false, skip_block_download_wait: false, disable_electrum_rpc: false, server_banner: "Umbrel Electrs (0.10.6)", signet_magic: f9beb4d9 } [2024-11-16T11:34:01.777Z INFO electrs::metrics::metrics_impl] serving Prometheus metrics on 127.0.0.1:4224 [2024-11-16T11:34:01.777Z INFO electrs::server] serving Electrum RPC on 0.0.0.0:50001 [2024-11-16T11:34:01.825Z INFO electrs::db] "/data/db/bitcoin": 100 SST files, 0.000101778 GB, 0.000000021 Grows [2024-11-16T11:34:01.840Z INFO electrs::db] closing DB at /data/db/bitcoin [2024-11-16T11:34:01.840Z WARN electrs::p2p] failed to shutdown p2p connection: Transport endpoint is not connected (os error 107) Error: electrs failed