electrumx icon indicating copy to clipboard operation
electrumx copied to clipboard

ElectrumX should accept local incoming connections even if it has not fully caught up with the bitcoin daemon

Open adrelanos opened this issue 2 years ago • 5 comments

Steps to reproduce:

  1. Setup ElectrumX.
  2. Setup electrum with oneserver connecting one's own ElectrumX server that was just set up and is not fully blockchain synced yet.

Expected result:

ElectrumX accepts local incoming connection.

Actual result:

ElectrumX does not accept local incoming3 connection.

Issue

Quote https://electrumx-spesmilo.readthedocs.io/en/latest/environment.html

ElectrumX will not serve any incoming connections until it has fully caught up with your bitcoin daemon.

I am arguing that this shouldn't be the case. Should be changed. This seems to be a bug at least in context of using electrum with one's own self-hosted, local ElectrumX server.

ElectrumX should be supporting a local rcp connection when not synced to the tip of the blockchain, at least if some option (environment variable) is configured.

Why is that an issue?

Unexpected and very difficult to figure out what's wrong.

It is highly unusual to open/close a server/service (local) port depending on some internal state (progress of blockchain synchronization). This is the first server application which I've ever seen which is doing this. For example, if nginx is configured but there is an issue with PHP, nginx will show an error message. It won't just close the server listening port.

Suggested Solution

Could you please add an environment variable TRUSTEDSERVER (or better name)? If enabled, always allow local incoming connections.

Related

electrum unwanted disconnect from own ElectrumX server

adrelanos avatar Dec 28 '21 12:12 adrelanos

Dunno what RDP is but RPC is always listening

kyuupichan avatar Jan 16 '22 16:01 kyuupichan

Indeed.

Quote https://electrumx-spesmilo.readthedocs.io/en/latest/environment.html

ElectrumX will not serve any incoming connections until it has fully caught up with your bitcoin daemon.

This is what I wanted to make this ticket about.

The only exception is local RPC connections, which are served at any time after the server has initialized.

Indeed. No issue with RPC.

I've updated my original post above to say "incoming connections" instead of RDP RPC. I.e.:

ElectrumX should accept local incoming connections even if it has not fully caught up with the bitcoin daemon

adrelanos avatar Jan 16 '22 17:01 adrelanos

The reason is that it cannot serve you correct answers to the queries you send, only incorrect ones, so there is no point.

kyuupichan avatar Jan 16 '22 18:01 kyuupichan

Sure, no correct/up to date answers can be sent.

But instead of not opening the listening port, which is unexpected and very difficult to figure out what's wrong, no other application is doing this to my knowledge...

Could you please consider opening the listening port and reply in the protocol not fully synced yet or more fancy not fully synced yet. Synced only block #xxx of #yyy. Expected time until fully synced: ... or something alike?

I guess electrum would/could understand this as "invalid reply" and disconnect. It might even disconnect faster since an open port that says "sorry, not ready yet" is faster than "hm, trying to connect, waiting for timeout".

Any other server software that isn't ready for whatever temporary or permanent error code (let's say e-mail, e-mail servers are doing that), will inform the connecting client software the temporary or permanent error code (in case of e-mail it will tell something like "temporary error, sorry, server is too busy, try again later" or "permanent error, sorry, this user does not exist". An e-mail server that is busy, will inform about that, but it won't just close the listen port.

adrelanos avatar Jan 16 '22 19:01 adrelanos

related https://github.com/spesmilo/electrumx/pull/90#issuecomment-971830830

SomberNight avatar Jan 18 '22 16:01 SomberNight