Surprising behavior of `--rpc-addr` when given wrong values
I accidentally passed wrong values to the --rpc-addr
argument of the node, and encountered some weird behavior.
Issue 1: passing a port
If you run with --rpc-addr 18732
, the node starts an RPC server on port 8732:
Nov 24 10:52:03.730 - node.main: starting RPC server on ::ffff:0.0.73.44:8732 (tls = false)
It is not listening on localhost
but on ::ffff:0.0.73.44
. I'm not sure how it chose to listen to this IPv6 address. Moreover it is listening to the default port (8732) instead of the one I specified.
Passing 18732
to --rpc-addr
is a mistake, I should have passed localhost:8732
for instance. But the result is surprising. I would expect 18732
to result in an error, or possibly in a result equivalent to localhost:8732
.
Issue 2: passing the same port as the P2P port
If you run with --rpc-addr '[::]:9732'
, the node starts with no error:
Nov 19 17:15:07.490 - node.main: read identity file (peer_id = idsxw1osqtv1Q3FfmxeUMRmuVNCJef)
Nov 19 17:15:07.490 - node.main: starting the Tezos node (chain = TEZOS_EBETANET_2020-11-19T15:01:32Z)
Nov 19 17:15:07.490 - node.main: disabled local peer discovery
Nov 19 17:15:07.493 - node: shell-node initialization: bootstrapping
Nov 19 17:15:07.494 - node: shell-node initialization: p2p_maintain_started
Nov 19 17:15:07.494 - block_validator_process_external: Initialized
Nov 19 17:15:08.012 - block_validator_process_external: Block validator started with pid 19993
Nov 19 17:15:08.048 - node.validator: activate chain NetXQiqBwsAGwPa
Nov 19 17:15:08.049 - p2p.maintenance: too few connections (0)
Nov 19 17:15:08.050 - node.chain_validator: no prevalidator filter found for protocol
Nov 19 17:15:08.050 - node.chain_validator: PtYuensgYBb3G3x1hLLbCmcav8ue8Kyd2khADcL5LsT5R1hcXex
Nov 19 17:15:08.051 - node.main: starting RPC server on :::9732 (tls = false)
Nov 19 17:15:08.051 - node.main: the Tezos node is now running
However, even though it says starting RPC server on :::9732 (tls = false)
, the RPC server is not reachable.
When I shut down my node with Ctrl+C, however, I got an error:
^C(tezos-node) INT: triggering shutdown.
(tezos-node) INT: triggering shutdown.
Nov 19 17:15:45.347 - node.main: shutting down the Tezos node
Nov 19 17:15:45.358 - p2p: Shutting down the p2p's welcome worker...
Nov 19 17:15:45.358 - p2p: Shutting down the p2p's network maintenance worker...
Nov 19 17:15:45.358 - p2p: Shutting down the p2p connection pool...
Nov 19 17:15:45.377 - p2p: Shutting down the p2p connection handler...
Nov 19 17:15:45.377 - p2p: Shutting down the p2p scheduler...
Nov 19 17:15:45.377 - node.distributed_db.requester: shutting down requester
Nov 19 17:15:45.377 - node.distributed_db.requester: shutting down requester
Nov 19 17:15:45.377 - node.validator: shutting down the block validator
Nov 19 17:15:45.377 - node.validator: shutting down the chain validator NetXQiqBwsAGwPa
Nov 19 17:15:45.378 - block_validator_process_external: Shutting down
Nov 19 17:15:45.378 - lwt-worker.validator-block: Worker validator-block:
Nov 19 17:15:45.378 - lwt-worker.validator-block: Failed with Exception: Unix.Unix_error(Unix.EPIPE, "write", "")
Nov 19 17:15:45.378 - node.distributed_db.requester: shutting down requester
Nov 19 17:15:45.378 - node.distributed_db.requester: shutting down requester
Nov 19 17:15:45.384 - node.main: shutting down the RPC server
(/home/nomadic/ebetanet/tezos/tezos-node) Exit: uncaught exception during clean-up (File "src/bin_node/node_run_command.ml", line 420, characters 11-18): Unix.Unix_error(Unix.EADDRINUSE, "bind", "")
(/home/nomadic/ebetanet/tezos/tezos-node) Exit: uncaught exception during clean-up (File "src/bin_node/node_run_command.ml", line 410, characters 11-18): Unix.Unix_error(Unix.EADDRINUSE, "bind", "")
(/home/nomadic/ebetanet/tezos/tezos-node) Exit: clean-up callback failed (File "src/bin_node/node_run_command.ml", line 410, characters 11-18): Unix.Unix_error(Unix.EADDRINUSE, "bind", "")
(/home/nomadic/ebetanet/tezos/tezos-node) Exit: clean-up callback failed (File "src/bin_node/node_run_command.ml", line 420, characters 11-18): Unix.Unix_error(Unix.EADDRINUSE, "bind", "")
tezos-node: Exited 255
The EPIPE
is probably unrelated. However the EADDRINUSE
shows that it tried to start a RPC server but failed because the port was already used by the P2P server.
I would expect:
- the
EADDRINUSE
error to appear sooner, beforethe Tezos node is now running
; - the error message to be more human-friendly, for instance
failed to start RPC server: address already in use (port: 9732)
.
One could also, additionally, check that the RPC port is different than the P2P port and write something like You configured your node to use the same port (9732) for both the RPC server and the P2P server. Please choose different ports. The default port for RPCs is 8732 and the default port for P2P is 9732.
Bonus issue: inconsistent RPC address format
In issue 2 we see the message: starting RPC server on :::9732 (tls = false)
but on the command-line we need to add brackets: [::]:9732
. The two should probably be made consistent with each other.